Skip to content

refactor: handle error results in sendStrictRequest - #2109

Merged
netomi merged 5 commits into
mainfrom
gnugomez/main/reduce-tanstack-boilerplate-code
Aug 31, 2026
Merged

refactor: handle error results in sendStrictRequest#2109
netomi merged 5 commits into
mainfrom
gnugomez/main/reduce-tanstack-boilerplate-code

Conversation

@gnugomez

Copy link
Copy Markdown
Member

This is just a quality-live improvement of the react query implementation, typically react query should be a thin layer wrapping the fetch client that would translate the promise into react-state, initially we created the sendNonRetriableRequest to allow react query to handle retries, that is working great, but we were manually throwing errors that the on every query/mutation hook.

This patch now moves all Tanstack Query hooks to use sendStrictRequest, it remains non-retirable, but at the same time it throws errors as exceptions, so react query will be able to catch it and convert feed it to the error state variable without any further boilerplate code.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Web UI’s TanStack Query integration so hooks and service calls consistently rely on sendStrictRequest, allowing error results (including 200 responses carrying { error: ... }) to be surfaced via promise rejection and handled by TanStack Query’s error state rather than per-hook isError boilerplate.

Changes:

  • Migrate multiple TanStack Query hooks and service endpoints to return “data-or-throw” by relying on sendStrictRequest and removing hook-level isError checks.
  • Update admin/dashboard UI code to treat successful mutation responses as SuccessResult (no as SuccessResult casts).
  • Add/adjust unit tests to reflect rejection-based failures and to cover sendStrictRequest behavior.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
webui/test/unit/server-request.spec.ts Adds unit coverage for sendStrictRequest and legacy sendNonRetriableRequest behavior.
webui/test/unit/pages/admin-dashboard/publisher-forget-user-button.spec.tsx Updates test to expect rejection-based failures for strict requests.
webui/test/unit/components/extension/extension-version-delete-dialog.spec.tsx Adds dialog tests expecting rejected removals and special handling for conflict (409).
webui/src/pages/user/extensions/use-user-extension.ts Simplifies query function by removing isError boilerplate.
webui/src/pages/home/use-home-data.ts Removes redundant error-result checks; relies on service rejection semantics.
webui/src/pages/admin-dashboard/use-publisher-admin.ts Converts publisher admin mutations to direct service calls (reject-on-failure).
webui/src/pages/admin-dashboard/use-namespace-admin.ts Simplifies namespace admin query/mutations to direct service calls.
webui/src/pages/admin-dashboard/use-extension-admin.ts Simplifies extension admin query/mutation wrappers to direct service calls.
webui/src/pages/admin-dashboard/publisher-details.tsx Treats mutation success response as typed SuccessResult (data.success).
webui/src/pages/admin-dashboard/namespace-change-dialog.tsx Removes SuccessResult cast; uses result.success directly.
webui/src/pages/admin-dashboard/customers/use-customers.ts Switches several customer mutations to direct service calls (no isError checks).
webui/src/hooks/use-infinite-search.ts Simplifies infinite search query to return service result directly.
webui/src/extension-registry-service.ts Migrates multiple endpoints to sendStrictRequest and narrows return types (drops `
webui/.agents/skills/tanstack-query-conventions/SKILL.md Updates internal guidance to reflect strict-request/error-handling conventions.
webui/.agents/skills/migrate-to-tanstack/SKILL.md Updates migration guidance to reflect strict-request semantics and test expectations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread webui/test/unit/server-request.spec.ts
Comment thread webui/.agents/skills/tanstack-query-conventions/SKILL.md Outdated
gnugomez and others added 3 commits August 31, 2026 08:58
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jordi Gómez Hidalgo <31970428+gnugomez@users.noreply.github.com>
sendRequest re-invoked itself without the caller's retry flag after
waiting out a 429, silently falling back to the default retry=true.
A sendStrictRequest/sendNonRetriableRequest call that hit a 429 could
end up having its follow-up request retried again by fetch-retry
itself, duplicating what the query client already owns.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Thomas Neidhart <thomas.neidhart@eclipse-foundation.org>
@netomi
netomi merged commit 469e9b2 into main Aug 31, 2026
5 checks passed
@netomi
netomi deleted the gnugomez/main/reduce-tanstack-boilerplate-code branch August 31, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants