fix: show clear error dialog for 403 whitelist failures (#10402)

## Summary
- When the cloud backend returns a 403 (user not whitelisted), the
frontend showed a generic "Prompt Execution Error" dialog with a cryptic
message
- Now catches 403 responses specifically and shows an "Access
Restricted" dialog with the backend's actual error message
- Adds `status` field to `PromptExecutionError` so error handlers can
distinguish HTTP status codes

## Changes
- `api.ts`: Added optional `status` to `PromptExecutionError`, pass
`res.status` from `queuePrompt`
- `app.ts`: New `else if` branch in the prompt error handler for `status
=== 403` — shows "Access Restricted" with the backend message

## Backwards compatible
- **Old backend** (`"not authorized"`): Shows "Access Restricted: not
authorized"
- **New backend**
([cloud#2941](https://github.com/Comfy-Org/cloud/pull/2941), `"your
account is not whitelisted for this feature"`): Shows "Access
Restricted: your account is not whitelisted for this feature"
- No behavior change for non-403 errors

## Related
- Backend fix: Comfy-Org/cloud#2941
- Notion: COM-16179

## Test plan
- [ ] Submit a prompt as a non-whitelisted user → should see "Access
Restricted" dialog with clear message
- [ ] Submit a prompt as a whitelisted user → no change in behavior
- [ ] Submit a prompt that fails for other reasons (missing nodes, etc.)
→ existing error handling unchanged

🤖 Generated with [Claude Code](https://claude.com/claude-code)

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10402-fix-show-clear-error-dialog-for-403-whitelist-failures-32c6d73d365081eb9528d7feac4e8681)
by [Unito](https://www.unito.io)

---------

Co-authored-by: Matt Miller <mattmiller@Matts-MacBook-Pro.local>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Miller
2026-03-23 16:57:12 -07:00
committed by GitHub
parent 2838edbb53
commit 6a9fb4e1d5
14 changed files with 68 additions and 14 deletions

View File

@@ -281,10 +281,12 @@ export interface ComfyApi extends EventTarget {
export class PromptExecutionError extends Error {
response: PromptResponse
status?: number
constructor(response: PromptResponse) {
constructor(response: PromptResponse, status?: number) {
super('Prompt execution failed')
this.response = response
this.status = status
}
override toString() {
@@ -901,7 +903,7 @@ export class ComfyApi extends EventTarget {
}
}
}
throw new PromptExecutionError(errorResponse)
throw new PromptExecutionError(errorResponse, res.status)
}
return await res.json()

View File

@@ -1647,6 +1647,34 @@ export class ComfyApp {
) {
// Re-scan the full graph instead of using the server's single-node response.
rescanAndSurfaceMissingNodes(this.rootGraph)
} else if (
error instanceof PromptExecutionError &&
error.status === 403
) {
// User is authenticated but not authorized (e.g. not whitelisted).
// Show a clear message instead of a generic error or sign-in prompt.
// The response may be middleware JSON {"message": "..."} or the
// standard {"error": {"message": "..."}} shape, so check both.
const raw =
error.response && typeof error.response === 'object'
? (error.response as Record<string, unknown>)
: {}
const rawError =
raw.error && typeof raw.error === 'object'
? (raw.error as Record<string, unknown>)
: undefined
const detail =
typeof raw.message === 'string'
? raw.message
: typeof rawError?.message === 'string'
? rawError.message
: typeof raw.error === 'string'
? raw.error
: t('errorDialog.accessRestrictedMessage')
useDialogService().showErrorDialog(new Error(detail), {
title: t('errorDialog.accessRestrictedTitle'),
reportType: 'accessRestrictedError'
})
} else if (
!useSettingStore().get('Comfy.RightSidePanel.ShowErrorsTab') ||
!(error instanceof PromptExecutionError)