Improve fetch request error reporting#1010
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughFetch failures now receive structured metadata, delegated errors are handled centrally, and localized sanitized messages include endpoint and browser error details. Tests cover classification, propagation, abort handling, escaping, concurrency, and API integrations. ChangesAPI request error handling
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant APIClient
participant fetchSSE
participant ContentScript
participant handlePortError
participant Port
APIClient->>fetchSSE: request API endpoint
fetchSSE-->>APIClient: classified fetch or stream error
APIClient->>ContentScript: delegated error
ContentScript->>handlePortError: pass classified error
handlePortError->>Port: post localized sanitized message
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request introduces robust error handling and localization for API fetch failures across multiple languages. It annotates fetch errors with a custom code and request origin, formats detailed error messages safely, and delegates them appropriately. The review feedback suggests enhancing the HTML escaping logic to prevent XSS vulnerabilities and handling cases where string errors are thrown instead of Error objects.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
PR Summary by QodoImprove fetch rejection error reporting with origin-aware, localized messages
AI Description
Diagram
High-Level Assessment
Files changed (22)
|
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (29 files)
Incremental review note: No new findings on changed lines since the prior review at Previous Review Summaries (8 snapshots, latest commit ebd2046)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit ebd2046)Status: No Issues Found | Recommendation: Merge Files Reviewed (8 files, incremental since 2ed5261)
Incremental review note: No new findings on changed lines since the prior review at
Previous review (commit 2ed5261)Status: No Issues Found | Recommendation: Merge Files Reviewed (12 files, incremental since c623fe3)
Incremental review note: No new findings on changed lines since the prior review at Previous review (commit c623fe3)Status: No Issues Found | Recommendation: Merge Files Reviewed (12 files, incremental since e8ce4bb)
Incremental review note: No new findings on changed lines since the prior review at Previous review (commit e8ce4bb)Status: No Issues Found | Recommendation: Merge Files Reviewed (23 files)
Incremental review note: No new findings on changed lines since the prior review at Previous review (commit 004a665)Status: No Issues Found | Recommendation: Merge Files Reviewed (23 files)
Incremental review note: No new findings on the changed lines since the prior review at Previous review (commit 5c0709d)Status: No Issues Found | Recommendation: Merge Files Reviewed (22 files)
Note: This is a full review (the prior incremental base SHA Previous review (commit 6ff41fe)Status: No Issues Found | Recommendation: Merge Files Reviewed (13 files)
Note: The previous WARNING on Previous review (commit e82dc96)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (17 files)
Note: Two existing active comments from Reviewed by hy3:free · Input: 83.6K · Output: 8.4K · Cached: 359K |
There was a problem hiding this comment.
Pull request overview
This PR improves how pre-response fetch() failures are classified and surfaced to users across API modes and the ChatGPT Web (content-script) path, aiming to provide a neutral, localized, and safer error summary that includes the request origin and the browser’s diagnostic message.
Changes:
- Classify
fetch()rejections infetchSSEwith a dedicatedFETCH_REQUEST_FAILEDcode plus a derivedrequestOrigin, while excludingAbortError. - Update shared port error handling to render a localized, neutral fetch-failure summary (with HTML-escaped details), and delegate certain content-script errors to the shared handler.
- Add i18n strings and regression tests covering classification, escaping, abort handling, and content-script delegation.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/utils/fetch-sse.test.mjs | Adds coverage for fetch rejection classification, origin derivation/omission, and abort behavior in fetchSSE. |
| tests/unit/services/handle-port-error.test.mjs | Adds tests for the new neutral fetch-failure summary, HTML escaping, and abort suppression in handlePortError. |
| tests/unit/services/apis/openai-api-compat.test.mjs | Updates network-error assertions to validate classified fetch rejection metadata (code, requestOrigin). |
| tests/unit/services/apis/custom-api.test.mjs | Updates network-error assertions to validate classified fetch rejection metadata (code, requestOrigin). |
| tests/unit/content-script/port-error.test.mjs | Adds unit tests for content-script error delegation rules and fallback formatting. |
| src/utils/fetch-sse.mjs | Introduces FETCH_REQUEST_FAILED classification and annotates fetch rejections with requestOrigin. |
| src/services/wrappers.mjs | Adds localized neutral messaging for classified fetch failures and HTML-escapes fetch failure details. |
| src/content-script/port-error.mjs | Adds delegation logic to route specific errors (classified fetch failures / aborts) to the shared handler. |
| src/content-script/index.jsx | Uses new delegation + message formatting helpers in the ChatGPT Web port listener error path. |
| src/_locales/en/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/de/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/es/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/fr/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/in/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/it/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/ja/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/ko/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/pt/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/ru/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/tr/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/zh-hans/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
| src/_locales/zh-hant/main.json | Adds localized strings for the neutral fetch-failure summary and details. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review by Qodo
1.
|
6ff41fe to
5c0709d
Compare
|
Code review by qodo was updated up to the latest commit 5c0709d |
5c0709d to
563547f
Compare
563547f to
004a665
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/services/wrappers.mjs`:
- Around line 94-102: Update the transportErrorSummaryKeys lookup in
handlePortError to accept only own properties, preventing inherited keys such as
constructor or toString from being treated as transport error codes. Preserve
the existing abort handling and translation flow for recognized transport codes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a99cfeb9-6adc-4e0e-b53d-463a2c24f42c
📒 Files selected for processing (23)
src/_locales/de/main.jsonsrc/_locales/en/main.jsonsrc/_locales/es/main.jsonsrc/_locales/fr/main.jsonsrc/_locales/in/main.jsonsrc/_locales/it/main.jsonsrc/_locales/ja/main.jsonsrc/_locales/ko/main.jsonsrc/_locales/pt/main.jsonsrc/_locales/ru/main.jsonsrc/_locales/tr/main.jsonsrc/_locales/zh-hans/main.jsonsrc/_locales/zh-hant/main.jsonsrc/content-script/index.jsxsrc/content-script/port-error.mjssrc/services/wrappers.mjssrc/utils/fetch-sse.mjstests/unit/content-script/port-error.test.mjstests/unit/services/apis/custom-api.test.mjstests/unit/services/apis/openai-api-compat.test.mjstests/unit/services/handle-port-error.test.mjstests/unit/services/wrappers-register.test.mjstests/unit/utils/fetch-sse.test.mjs
🚧 Files skipped from review as they are similar to previous changes (19)
- src/_locales/ja/main.json
- src/_locales/zh-hant/main.json
- src/_locales/in/main.json
- src/_locales/es/main.json
- src/_locales/ru/main.json
- src/_locales/fr/main.json
- src/_locales/it/main.json
- src/_locales/de/main.json
- src/content-script/port-error.mjs
- src/content-script/index.jsx
- tests/unit/services/apis/openai-api-compat.test.mjs
- src/_locales/pt/main.json
- src/_locales/en/main.json
- src/_locales/tr/main.json
- tests/unit/content-script/port-error.test.mjs
- src/utils/fetch-sse.mjs
- src/_locales/ko/main.json
- tests/unit/services/wrappers-register.test.mjs
- tests/unit/services/handle-port-error.test.mjs
004a665 to
e8ce4bb
Compare
|
Code review by qodo was updated up to the latest commit e8ce4bb |
e8ce4bb to
c623fe3
Compare
|
Code review by qodo was updated up to the latest commit c623fe3 |
c623fe3 to
2ed5261
Compare
|
Code review by qodo was updated up to the latest commit 2ed5261 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/ConversationCard/index.jsx`:
- Around line 257-266: The error-handling update around lastItem must use a
functional setConversationItemData state update so it reads the latest
conversation items when appending the error. Preserve the existing
duplicate/loading check and updateAnswer behavior, but avoid spreading the stale
conversationItemData closure captured by the listener.
In `@src/services/clients/bing/index.mjs`:
- Around line 407-413: Remove the raw console.error call from the ws.onerror
handler and only process the event through createWebSocketError(error). Preserve
the existing conditional assignment to webSocketError and
abortController.abort() based on the sanitized error message, ensuring the
unredacted WebSocket event is never logged.
In `@tests/unit/services/clients/bing.test.mjs`:
- Around line 104-107: Replace the double-quoted string literals at
tests/unit/services/clients/bing.test.mjs:104-107 and 235-238 with single-quoted
strings, escaping embedded double quotes as needed; also update the instruction
string at tests/unit/utils/error-text.test.mjs:49-53 to use single quotes and
escape its contraction.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 040bef6d-f935-4f3c-ba36-32b74b312b46
📒 Files selected for processing (29)
src/_locales/de/main.jsonsrc/_locales/en/main.jsonsrc/_locales/es/main.jsonsrc/_locales/fr/main.jsonsrc/_locales/in/main.jsonsrc/_locales/it/main.jsonsrc/_locales/ja/main.jsonsrc/_locales/ko/main.jsonsrc/_locales/pt/main.jsonsrc/_locales/ru/main.jsonsrc/_locales/tr/main.jsonsrc/_locales/zh-hans/main.jsonsrc/_locales/zh-hant/main.jsonsrc/components/ConversationCard/index.jsxsrc/content-script/index.jsxsrc/content-script/port-error.mjssrc/services/clients/bing/index.mjssrc/services/wrappers.mjssrc/utils/abort-error.mjssrc/utils/error-text.mjssrc/utils/fetch-sse.mjstests/unit/content-script/port-error.test.mjstests/unit/services/apis/custom-api.test.mjstests/unit/services/apis/openai-api-compat.test.mjstests/unit/services/clients/bing.test.mjstests/unit/services/handle-port-error.test.mjstests/unit/services/wrappers-register.test.mjstests/unit/utils/error-text.test.mjstests/unit/utils/fetch-sse.test.mjs
🚧 Files skipped from review as they are similar to previous changes (20)
- src/_locales/es/main.json
- src/_locales/zh-hant/main.json
- src/content-script/port-error.mjs
- src/_locales/it/main.json
- tests/unit/services/apis/custom-api.test.mjs
- src/_locales/fr/main.json
- src/_locales/en/main.json
- src/_locales/tr/main.json
- src/_locales/ja/main.json
- src/_locales/ko/main.json
- src/_locales/ru/main.json
- src/content-script/index.jsx
- src/_locales/pt/main.json
- src/_locales/zh-hans/main.json
- tests/unit/services/apis/openai-api-compat.test.mjs
- src/_locales/de/main.json
- tests/unit/services/wrappers-register.test.mjs
- src/utils/fetch-sse.mjs
- src/services/wrappers.mjs
- tests/unit/utils/fetch-sse.test.mjs
2ed5261 to
ebd2046
Compare
|
Code review by qodo was updated up to the latest commit ebd2046 |
Classify invalid endpoints, pre-response request failures, and response stream interruptions separately so the UI can provide localized, actionable guidance without guessing the underlying cause. Include only request origins and preserve browser diagnostics for troubleshooting. Keep aborts silent, escape dynamic details, and scope translations to each request.
ebd2046 to
59c2a93
Compare
|
Code review by qodo was updated up to the latest commit 59c2a93 |
Summary
Validation
npm run prettynpm run lintnpm test(791 passed)npm run builddiagnosticblocks remain inert and unhighlighted in both browsers while JSON diagnostics retain syntax highlightingSummary by CodeRabbit
%splaceholders for endpoint and browser message.