{"record":{"id":"359dfb56bf575580","repo":"BloopAI/vibe-kanban","slug":"result-message-t-createworkspacefrompr-errors","errorCode":null,"errorMessage":"result.message || t('createWorkspaceFromPr.errors.failedToCreateWorkspace')","messagePattern":"result\\.message \\|\\| t\\('createWorkspaceFromPr\\.errors\\.failedToCreateWorkspace'\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/web-core/src/shared/dialogs/command-bar/CreateWorkspaceFromPrDialog.tsx","lineNumber":171,"sourceCode":"          switch (result.error?.type) {\n            case 'branch_fetch_failed':\n              throw new Error(result.error.message);\n            case 'auth_failed':\n              throw new Error(result.error.message);\n            case 'cli_not_installed':\n              throw new Error(\n                t('createWorkspaceFromPr.errors.cliNotInstalled', {\n                  provider: result.error.provider,\n                })\n              );\n            case 'pr_not_found':\n              throw new Error(t('createWorkspaceFromPr.errors.prNotFound'));\n            case 'unsupported_provider':\n              throw new Error(\n                t('createWorkspaceFromPr.errors.unsupportedProvider')\n              );\n            default:\n              throw new Error(\n                result.message ||\n                  t('createWorkspaceFromPr.errors.failedToCreateWorkspace')\n              );\n          }\n        }\n        return result.data;\n      },\n      onSuccess: (data) => {\n        queryClient.invalidateQueries({ queryKey: ['tasks'] });\n        queryClient.invalidateQueries({ queryKey: ['workspaces'] });\n        modal.hide();\n        appNavigation.goToWorkspace(data.workspace.id);\n      },\n    });\n\n    useEffect(() => {\n      if (!modal.visible) {\n        setSelectedRepoId(null);","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/packages/web-core/src/shared/dialogs/command-bar/CreateWorkspaceFromPrDialog.tsx#L153-L189","documentation":"This is the default arm of the createFromPr result switch: when success is false and error.type matches none of the known CreateFromPrError variants, the dialog throws result.message (backend-provided generic message) or falls back to the localized failedToCreateWorkspace string. It represents any unrecognized creation failure returned by the backend.","triggerScenarios":"workspacesApi.createFromPr resolves success:false with an error.type outside {branch_fetch_failed, auth_failed, cli_not_installed, pr_not_found, unsupported_provider}, or result.message is set while error is absent/unknown; thrown as the mutation error and shown in the dialog.","commonSituations":"Shared type drift between frontend and backend after an upgrade adds a new CreateFromPrError variant; transient backend/internal errors surfaced with only a top-level message; serialization mismatch producing an unclassifiable payload.","solutions":["Read result.message in the devtools/network response for the real backend error text","Rebuild/regenerate shared types (pnpm run generate-types) so frontend and backend CreateFromPrError variants match","Retry the operation; if it persists, check backend logs for the workspace creation request","Add a case for the new error type in the switch if a new variant was introduced upstream"],"exampleFix":"// before\nexport type CreateFromPrError = ... | { type: 'unsupported_provider' };\n// after (regenerated after backend added a variant)\nexport type CreateFromPrError = ... | { type: 'unsupported_provider' } | { type: 'new_variant', message: string };","handlingStrategy":"try-catch","validationCode":"// keep the frontend's CreateFromPrError in sync; CI check:\n// pnpm run generate-types:check — fails when shared/types.ts diverges from the Rust source","typeGuard":"function hasKnownErrorType(e: unknown): e is CreateFromPrError {\n  const known = ['pr_not_found','branch_fetch_failed','cli_not_installed','auth_failed','unsupported_provider'];\n  return typeof e === 'object' && e !== null && 'type' in e && known.includes((e as { type: string }).type);\n}","tryCatchPattern":"try {\n  const result = await workspacesApi.createFromPr(input);\n  if (!result.success) {\n    if (hasKnownErrorType(result.error)) throw new Error(describe(result.error));\n    throw new Error(result.message ?? t('createWorkspaceFromPr.errors.failedToCreateWorkspace'));\n  }\n} catch (err) {\n  logToTelemetry('create_from_pr_unclassified', { raw: (err as Error).message });\n  show((err as Error).message);\n}","preventionTips":["Regenerate shared types whenever backend error enums change (pnpm run generate-types)","Always carry a top-level `message` in error responses for fallback display","Add exhaustive switch checks (`satisfies never`) so new variants break the build","Log unclassified error payloads for diagnosis"],"tags":["fallback","api","types"],"backgroundTag":"unhandled-api-error-variant","analyzedSha":"4deb7eca8f381f7cbc1f9d15515a9ab8f8009053","analyzedAt":"2026-08-29T09:24:13.446Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}