-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api, worker, application-generic): Add exhaustive error handling for bridge requests #6715
Merged
rifont
merged 6 commits into
next
from
nv-4502-add-exhaustive-error-handling-for-bridge-requests
Oct 17, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d380275
refactor(error handling): improve error handling logic
rifont 1eac637
fix(sync): handle HttpException in sync usecase
rifont 39e7799
refactor: update error handling logic
rifont 2d48601
fix(execute-bridge-request): handle error code condition
rifont 5a6c1f6
Merge branch 'next' into nv-4502-add-exhaustive-error-handling-for-br…
rifont d0f7987
refactor: use discrete if statements per error for readability
rifont File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,12 +249,23 @@ export class ExecuteBridgeJob { | |
let raw: { retryCount?: number; statusCode?: number; message: string; url?: string }; | ||
|
||
if (error.response) { | ||
let rawMessage: Record<string, unknown>; | ||
const errorResponseBody = error?.response?.body; | ||
try { | ||
rawMessage = JSON.parse(errorResponseBody); | ||
} catch { | ||
Logger.error(`Unexpected body received from Bridge: ${errorResponseBody}`, LOG_CONTEXT); | ||
rawMessage = { | ||
error: `Unexpected body received from Bridge: ${errorResponseBody}`, | ||
}; | ||
} | ||
|
||
raw = { | ||
url: statelessBridgeUrl, | ||
statusCode: error.response?.statusCode, | ||
message: error.response?.statusMessage, | ||
...(error.response?.retryCount ? { retryCount: error.response?.retryCount } : {}), | ||
...(error?.response?.body?.length > 0 ? { raw: JSON.parse(error?.response?.body) } : {}), | ||
...(error?.response?.body?.length > 0 ? { raw: rawMessage } : {}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this lack of error handling during body parsing was contributing to execution detail logs not surfacing due to an inability to parse the error body. This was observed with errors such as "BSON circular value cannot be converted..." |
||
}; | ||
} else if (error.message) { | ||
raw = { | ||
|
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplifying the error thrown here.
Let non-HTTP exceptions bubble up to the API exception handler.