fix: warehouse graceful termination - replace panic with error handling#3
Merged
Merged
Conversation
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="warehouse/router/identities.go">
<violation number="1" location="warehouse/router/identities.go:302">
P1: Returning `model.Upload{}` on setup failures hides the error and allows the identity population flow to continue with an invalid upload (ID 0/empty fields). Propagate an error to the caller and stop processing instead of returning a zero-value upload.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| if err != nil { | ||
| panic(err) | ||
| r.logger.Errorn("[WH]: Failed to marshal schema for identity upload", obskit.Error(err)) | ||
| return model.Upload{} |
There was a problem hiding this comment.
P1: Returning model.Upload{} on setup failures hides the error and allows the identity population flow to continue with an invalid upload (ID 0/empty fields). Propagate an error to the caller and stop processing instead of returning a zero-value upload.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At warehouse/router/identities.go, line 302:
<comment>Returning `model.Upload{}` on setup failures hides the error and allows the identity population flow to continue with an invalid upload (ID 0/empty fields). Propagate an error to the caller and stop processing instead of returning a zero-value upload.</comment>
<file context>
@@ -297,7 +298,8 @@ func (r *Router) initPrePopulateDestIdentitiesUpload(warehouse model.Warehouse)
if err != nil {
- panic(err)
+ r.logger.Errorn("[WH]: Failed to marshal schema for identity upload", obskit.Error(err))
+ return model.Upload{}
}
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses PR rudderlabs#6767
Changes:
Summary by cubic
Replaced panics in warehouse routing with error handling and logging so the service fails safely and can terminate gracefully instead of crashing.
warehouse/router/identities.go: log and return on manager init, schema marshal, upload ID scan, and identity population failures (usesr.logger.Errornwithobskit.Error(err)), returning errors ormodel.Upload{}as appropriate.warehouse/router/state.go:inProgressStatenow returns an empty string on invalid state instead of panicking.Written for commit 5dd7b2e. Summary will update on new commits.