Skip to content

fix: match sanitized query errors in isPermissionDenied and adopt it in McpHealthCard - #70

Open
Altamimi-Dev wants to merge 1 commit into
contextforge-org:mainfrom
Altamimi-Dev:65-permission-denied-helper
Open

fix: match sanitized query errors in isPermissionDenied and adopt it in McpHealthCard#70
Altamimi-Dev wants to merge 1 commit into
contextforge-org:mainfrom
Altamimi-Dev:65-permission-denied-helper

Conversation

@Altamimi-Dev

Copy link
Copy Markdown
Contributor

Closes #65.

McpHealthCard now uses isPermissionDenied(error) instead of the inline error?.status === 403, so new gated cards have one canonical predicate to reuse.

One deviation from the issue text: the helper's instanceof ApiError narrowing can never match at this call site. useQuery sanitizes thrown errors into a plain { message, status, code, body } object (sanitizeError in src/hooks/useQuery.ts), so the error a card sees is never an ApiError instance. Adopting the helper unchanged would have silently broken the PermissionDenied gate; the existing card tests, which mock the sanitized shape, catch exactly this. The helper now does a structural status === 403 check, which matches both a raw ApiError and the sanitized query-error shape, with a doc comment explaining why, plus unit tests.

Per the issue's scope note, the domain-specific 403 checks in loginErrors.ts, passwordResetErrors.ts and changePasswordRequiredErrors.ts are untouched, as are utils/errors.ts and the useMiniCardStatuses definitive-error classification.

…in McpHealthCard

useQuery sanitizes thrown ApiErrors into plain objects, so the helper's
instanceof check never matched a query error. Make it structural and use
it for the McpHealthCard 403 gate.

Signed-off-by: Ahmad Al Tamimi <altamimi.dev@gmail.com>
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.

Use the isPermissionDenied helper in McpHealthCard instead of an inline 403 check

1 participant