fix(oc-docs): contextual error messages for failed try-it requests (BRU-3408)#40
Open
sundram-bruno wants to merge 1 commit into
Open
Conversation
sachin-bruno
approved these changes
Jun 11, 2026
…RU-3408) Browser fetch collapses CORS, DNS, connection-refused, offline and TLS into one opaque "Failed to fetch", so the old code mislabeled every failure as a definite "CORS error" and never caught timeouts. Classify failures from request context instead of the opaque message: - timeout, mixed-content, browser-blocked (CORS / file origin), unreachable (same-origin), uncategorized - never assert CORS as certain; same-origin failures never mention CORS - render a danger banner inside the Response tab (tab shell preserved, status bar hidden), matching Bruno desktop's error banner - style via theme.generated.css tokens (--oc-status-danger-*, --oc-border-border2) Adds classifyRequestError unit tests and Playwright e2e for the browser-blocked, unreachable and 4xx-is-not-a-failure cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
f32a4ec to
fbd659a
Compare
Contributor
Author
|
Updated: rebased onto current The error banner is now styled entirely via Verified live in collection docs: browser-blocked, unreachable, timeout, and unknown all render correctly; 13 unit + 3 e2e green. |
bijin-bruno
approved these changes
Jun 17, 2026
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.
Problem
A failed try-it request in the collection docs showed only an opaque "Request Failed / Failed to fetch", and the runner hardcoded every network failure as a
"CORS error"— including connection-refused, same-origin, and timeouts (see opencollection #24). Timeouts were also missed: the catch checked forAbortError, butAbortSignal.timeout()throws aTimeoutError, so real timeouts leaked the raw"signal timed out".JIRA : https://usebruno.atlassian.net/browse/BRU-3408
Approach
Browser
fetchcollapses CORS, DNS, connection-refused, offline, and TLS into one opaque failure with no detail — the real cause lives only in devtools. So we classify from the request context the browser does expose (timeout, page vs target scheme, same-origin vs cross-origin / file), not the error text.Five cases
https, targethttpSame-vs-different is compared by origin (scheme+host+port), not site, because CORS is enforced per-origin (
https://docs.example.com→https://api.example.comis cross-origin even though both areexample.com). CORS is suggested only for cross-origin or opened-from-file failures, never same-origin (AC #2).Changes
classifyRequestError— pure classifier returning{ type, title, message }; takes the resolved request URL + the page URL (window.location.href, passed in to stay pure). Unparseable URL → underlying message.RequestExecutor— catch delegates to the classifier; removed the hardcoded CORS string and the deadnetwork/sslbranchesfetchcan never produce.ErrorBanner— small reusable UI (bold title + monospace message) mirroring Bruno desktop's response error banner.ResponsePane— banner renders inside the Response tab (consistent with a success response); status bar hidden on failure (no HTTP status exists).4xx/5xxremain normal responses. Response display, default timeout, and OAuth2 handling are unchanged.Tests
classifyRequestError.spec.ts): all five cases + edges (cross-origin, file origin, same-origin never-CORS, unparseable URL, non-Error throw).request-errors.spec.ts): cross-origin → browser-blocked (inside Response tab), same-origin → unreachable (never mentions CORS), 4xx → renders normally. First e2e to actually drive Try → Send; usespage.routefor deterministic failures.All existing e2e (63) and unit tests pass; new code is lint-clean.
Acceptance criteria