Tell an admin when a query failed instead of showing nothing - #45
Merged
Conversation
The other half of 4a3dcb3. That commit fixed the 403 case -- a revoked admin was seeing an empty dashboard rather than being told -- but left every other failure flattened to null by util/api.ts, with the same consequence: react-query settles a null as success-with-no-data, so a 500 or a dropped connection rendered "No submissions yet" or "Not found". That is a lie about other people's data, and the sort of lie an admin acts on. The admin fetchers now sort the outcomes into three. 403 still throws AdminAccessError. 404 still returns null, because that one really is an answer -- no member matches that address -- and the pages keep their own copy for it. Everything else throws, so isError is true and the pages can say so. AdminError is the shared screen, built on the existing ErrorAlert that Forms.tsx already uses for a failed submit. It carries a Try again button: admin queries set retry: false, since a 403 is a settled answer and retrying meant three more of them with a GitHub resync behind each, so a transient 500 has nothing to recover it unless the person asks. It also says outright that access is not the problem, because the dashboard's only other failure state is a revoked admin and an unqualified error would read as that. Each page checks isError ahead of isPending and its own empty state, and stays behind the revoked check so a 403 still routes to AdminGate rather than showing both.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
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.
Stacked on #43 — base is
feat/admin-dashboard, so merge that one first.Picks up the loose end from the CodeRabbit review on #43, and finishes what
4a3dcb3started there.The problem
4a3dcb3fixed the 403 case: a revoked admin was seeing an empty dashboard instead of being told. Every other failure was still flattened tonullinutil/api.ts, with the same consequence — react-query settles anullas success-with-no-data, so a 500 or a dropped connection rendered "No submissions yet" or "Not found".That is a lie about other people's data, and the sort an admin acts on. "There were no maintainer signups in 2026" is a conclusion someone might reasonably draw and then repeat.
The change
The admin fetchers sort outcomes into three instead of two:
AdminAccessErroruseAdminAccessrefetches the session soAdminGatecan say access was revokednullisErrorgoes true and the page says soAdminErroris the shared screen, built on the existingErrorAlertthatForms.tsxalready uses for a failed submit — no new error styling.Two deliberate details:
retry: false(a 403 is a settled answer, and retrying meant three more with a GitHub resync behind each). So a transient 500 has nothing to recover it unless the person asks.Each page checks
isErrorahead ofisPendingand its own empty state, and stays behind therevokedcheck so a 403 still routes toAdminGaterather than rendering both.Verification
pnpm typecheckandpnpm buildpass; prettier clean. Not exercised in a browser — reproducing it wants a forced 5xx from the admin routes, and there are no tests over these pages.