Skip to content

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

Merged
vishu-bh merged 1 commit into
contextforge-org:mainfrom
Altamimi-Dev:65-permission-denied-helper
Aug 24, 2026
Merged

fix: match sanitized query errors in isPermissionDenied and adopt it in McpHealthCard#70
vishu-bh merged 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>

@marekdano marekdano 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.

The PR looks good!

LGTM 🚀

@marekdano marekdano self-assigned this Aug 24, 2026

@vishu-bh vishu-bh 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.

Thanks @Altamimi-Dev. LGMT 🚀

@vishu-bh
vishu-bh merged commit e28d7ac into contextforge-org:main Aug 24, 2026
5 checks passed
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

3 participants