WEB-965: use parsed errorBody consistently in ErrorHandlerInterceptor#3610
WEB-965: use parsed errorBody consistently in ErrorHandlerInterceptor#3610RiteshGite wants to merge 1 commit into
Conversation
|
Note
|
| Layer / File(s) | Summary |
|---|---|
Error message extraction and normalization src/app/core/http/error-handler.interceptor.ts |
Lines 95–106 refactor errorMessage derivation from errorBody.errors[0] with safer optional chaining on defaultUserMessage/developerMessage; database-integrity detection now uses includes() to check userMessageGlobalisationCode and translates matching codes to a fixed integrity-issue message; non-integrity paths clean up messages by replacing dots with spaces via regex. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
- openMF/web-app#3452: Both PRs modify
src/app/core/http/error-handler.interceptor.tsto refine howerrorMessageis derived from HTTP error payloads usinguserMessageGlobalisationCodeanderrorBody.errors[0].
Suggested reviewers
- alberto-art3ch
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Title check | ✅ Passed | The title 'WEB-965: use parsed errorBody consistently in ErrorHandlerInterceptor' accurately summarizes the main change: using parsed errorBody instead of response.error in the error handler. |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
IOhacker
left a comment
There was a problem hiding this comment.
Could you please add an evidence of the change?
|
@IOhacker Added evidence for the reported issue along with before/after screenshots. Please review again. Thanks! |
|
@RiteshGite Thanks for adding the evidence videos. Could you also add an after-fix video for the same scenarios instead of only a screenshot? Right now, the screenshot does not clearly demonstrate:
A short validation recording covering the same cases after the fix would make verification much clearer for reviewers. |
|
@Flashl3opard Added after-fix validation videos for the same scenarios as requested. Please take a look when you get a chance. Thanks! |
Description
Prevents runtime crashes in
ErrorHandlerInterceptorwhen handling malformed orArrayBuffer-based API error responses.This change updates the interceptor to consistently use the parsed
errorBodyinstead of directly accessingresponse.error. It also safely handles nullable error fields using optional chaining and preserves fallback error message behavior.This fixes cases where the global error handler could fail when:
ArrayBuffererrors[0]was missingdefaultUserMessageordeveloperMessagewasnull/undefinedRelated Issues and Discussion
#WEB-965
Reproduction Steps
To validate the unsafe cases, the interceptor's
intercept()method was temporarily modified to force specific error payloads.Scenario 1: Empty
errorsarrayTemporary code used
Expected issue before fix: Runtime error when the code tries to access
errorBody.errors[0].Scenario 2:
nulldefaultUserMessageTemporary code used
Expected issue before fix: Runtime error when
.replace()is called onnull.Screenshots & Videos
Before Fix
1. Empty errors array — crash
EmptyArray.mp4
2. Null defaultUserMessage — crash
nullError.mp4
After Fix
1. Empty errors array — handled gracefully
EmptyArray_Error_Handled.mp4
2. Null defaultUserMessage — handled gracefully
Null_Error_Handled.mp4
3. Error handler working correctly
Final_Output_With_Original_Intercepter_And_Updated_Error_Handler.mp4
Checklist
Please make sure these boxes are checked before submitting your pull request — thanks!
web-app/.github/CONTRIBUTING.md.