Skip to content

fix(ui): flag a failed query that has no error body - #542

Open
jsenecal wants to merge 1 commit into
mainfrom
fix/509-error-without-body
Open

jsenecal wants to merge 1 commit into
mainfrom
fix/509-error-without-body

Conversation

@jsenecal

@jsenecal jsenecal commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Merge after #536. The AbortError mapping below relies on the #511 fix in #536 (a fresh controller per request, timer cleared on settle). On main without it, a requery more than requestTimeout after a successful query would reject at once and show "Request timed out.".

Problem

Result (components/results/individual.tsx) decided whether a result was an error from the response body alone:

const isError = useMemo(() => isLGOutputOrError(data), [data, error]);

A request that fails without an error body (a timeout, a network error, a response that is not JSON) leaves data undefined and sets only error. isError was false, so the panel stayed collapsed and the header showed the success icon and "Completed in 0 seconds". The message errorMsg builds from error was never shown.

A timeout also showed the wrong text. fetchWithTimeout aborts the request, and fetch rejects with an AbortError whose message is "This operation was aborted". errorMsg only used messages.requestTimeout when the message started with "timeout", so a timed-out query would have shown "This Operation Was Aborted".

Change

  • individual.tsx: isError is also true when the query has an error. The panel expands with the error alert, and the header shows the error icon with the error message as its tooltip. The cache countdown stays hidden. The same applies when a requery fails after a successful query: the error replaces the old output (the copy button already copied the error text in that case).
  • individual.tsx: errorMsg maps an AbortError to the configured messages.requestTimeout. After Requery fails at once after requestTimeout because the abort controller is reused #511 (fixed in fix(ui): give each query request its own abort controller and timeout #536), an AbortError only comes from the request timeout or from unmounting, and an unmounted result shows nothing.
  • individual.tsx: case 'warning' || 'error': in setErrorLevel evaluated to case 'warning':; it is now written that way. No behaviour change, since 'error' is the default.
  • individual.test.tsx: the test(ui): cover results, layout and the index page #505 test "leaves a failed request collapsed and unflagged", which documented the bug, is replaced by "expands and flags %s as an error" for a timeout (DOMException AbortError), a network error (TypeError('Failed to fetch')) and a non-JSON response. Each checks the expanded panel, the alert text and level, the error icon and its tooltip, and that the cache countdown is hidden. The separate non-JSON status-text test is folded into it. A new test covers a requery that fails after a success. The success tooltip test also checks the header doesn't show the error icon. The failed() helper is gone: failed queries now expand, so the other error tests use settled().

The error icon is identified by comparing the drawing (path d) of the header icon with react-icons' BiError.

Tests

With origin/main's individual.tsx and the new tests, 9 tests fail. The 5 existing "shows the message for ..." cases fail too, because they now wait for the panel to expand:

 FAIL  components/results/individual.test.tsx > Result > errors > shows the message for a timeout
 FAIL  components/results/individual.test.tsx > Result > errors > shows the message for a failed request
 FAIL  components/results/individual.test.tsx > Result > errors > shows the message for a bad HTTP response
 FAIL  components/results/individual.test.tsx > Result > errors > shows the message for an error response
 FAIL  components/results/individual.test.tsx > Result > errors > shows the message for an unknown error
 FAIL  components/results/individual.test.tsx > Result > errors > expands and flags a timed out request as an error
 FAIL  components/results/individual.test.tsx > Result > errors > expands and flags a network error as an error
 FAIL  components/results/individual.test.tsx > Result > errors > expands and flags a response that is not JSON as an error
 FAIL  components/results/individual.test.tsx > Result > errors > shows the error when a requery fails
      Tests  9 failed | 16 passed (25)

With only the AbortError mapping reverted, 1 test fails:

 FAIL  components/results/individual.test.tsx > Result > errors > expands and flags a timed out request as an error
      Tests  1 failed | 24 passed (25)

With the fix: biome format, biome lint, tsc --noEmit and test pass; Tests 206 passed (206).

Changelog

Notes

Closes #509

`Result` decided whether a result was an error from the response body
alone. A request that failed without one (a timeout, a network error, a
response that is not JSON) left `data` undefined, so the panel stayed
collapsed and its header showed the success icon and "Completed in 0
seconds". The error message built from `error` was never shown.

Treat any query error as an error result, so the panel expands with the
error message and the header shows the error icon. A requery that fails
after a successful query now shows its error instead of the old output.

A timeout reaches `Result` as an `AbortError` whose message doesn't
mention the timeout, so it showed "This Operation Was Aborted" instead
of the configured `messages.requestTimeout`. Map `AbortError` to that
message too.

Also fix `case 'warning' || 'error':` in `setErrorLevel`, which only
matched 'warning'. The result was the same, since 'error' is the
default.

The result-panel test that documented the old behaviour now asserts the
error state for a timeout, a network error and a non-JSON response.
@jsenecal jsenecal added bug Confirmed bug or unexpected behavior frontend Next.js UI and the runtime UI build labels Nov 21, 2026
@jsenecal jsenecal self-assigned this Nov 21, 2026
@jsenecal
jsenecal requested a review from WilhelmZA November 21, 2026 04:48
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 85.35% (-0.005%) from 85.355% — fix/509-error-without-body into main

@WilhelmZA WilhelmZA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 8f27e673.

The change is correct: isError now covers a failure with no error body, an AbortError maps to messages.requestTimeout, and the tests replace the one from #505 that documented the bug. CI gate passes and the commit is verified.

Before approval:

  • The AbortError mapping depends on the #511 fix in #536, which is not merged. On main, useLGQuery keeps one controller per panel and fetchWithTimeout never clears its timer. If this PR merges first, a requery more than requestTimeout after a successful query rejects at once, and the panel shows "Request timed out." although no request was sent. Please merge #536 first, or state in the body that this PR waits for #536.
  • The body names #511 as the change that edits hooks/use-lg-query.test.tsx. #511 is the issue; the PRs are #536 and #563. The body also says #534 is still open, and it has merged.

#564 and #565 also change results/individual.tsx.

Nits:

  • The body has a Changelog entry but CHANGELOG.md is not edited. Please add it under [Unreleased], here or in the release PR.

@WilhelmZA WilhelmZA added the reviewing Issue is being reviewed by maintainers label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Confirmed bug or unexpected behavior frontend Next.js UI and the runtime UI build reviewing Issue is being reviewed by maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A failed query with no error body is shown as a successful result

3 participants