{"record":{"id":"5f4b316e70ac772a","repo":"different-ai/openwork","slug":"app-error-request-failed","errorCode":null,"errorMessage":"app.error_request_failed","messagePattern":"app\\.error_request_failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/session/sync/actions-store.ts","lineNumber":302,"sourceCode":"    if (raw && !generic && raw !== heading) lines.push(raw);\n    if (status && !heading.includes(String(status))) lines.push(`Status: ${status}`);\n    if (provider && !heading.includes(provider)) lines.push(`Provider: ${provider}`);\n    if (code) lines.push(`Code: ${code}`);\n    if (response) lines.push(`Response: ${response}`);\n    if (lines.length > 1) return lines.join(\"\\n\");\n\n    if (raw && !generic) return raw;\n    if (error && typeof error === \"object\") {\n      const serialized = safeStringify(error);\n      if (serialized && serialized !== \"{}\") return serialized;\n    }\n    return fallback;\n  };\n\n  const assertNoClientError = (result: unknown) => {\n    const maybe = result as { error?: unknown } | null | undefined;\n    if (!maybe || maybe.error === undefined) return;\n    throw new Error(describeProviderError(maybe.error, t(\"app.error_request_failed\")));\n  };\n\n  const lastPromptSent = () => snapshot.lastPromptSent;\n\n  const selectedSessionAgent = () => {\n    const id = options.selectedSessionId();\n    if (!id) return null;\n    return snapshot.sessionAgentById[id] ?? null;\n  };\n\n  const sessionRevertMessageId = () => options.selectedSession()?.revert?.messageID ?? null;\n\n  async function createReadySession(workspaceId: string, initialPrompt?: string) {\n    const id = workspaceId.trim();\n    if (!id) return undefined;\n    const c = options.client();\n    if (!c) {\n      return undefined;","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/session/sync/actions-store.ts#L284-L320","documentation":"assertNoClientError inspects a result object for an error field and throws an Error whose message is describeProviderError(maybe.error, t(\"app.error_request_failed\")). The literal 'app.error_request_failed' surfaces when the error value couldn't be described into a friendlier message (missing translation or undescribable error shape), so the user sees the generic localized fallback key. It marks a client-side/provider request that returned an error payload.","triggerScenarios":"sendPrompt receives a result containing an error property from the provider/client layer, and describeProviderError falls back to the t(\"app.error_request_failed\") translation — either because the error object has no recognizable shape or the i18n key is missing from the active locale.","commonSituations":"Provider API returned an error (rate limit, invalid model, bad API key) that the error-describer doesn't recognize; missing translation entry for app.error_request_failed in a custom locale file.","solutions":["Log the raw error payload (maybe.error) at the call site to find the real underlying provider error and fix that (API key, model ID, quota).","Ensure the app.error_request_failed key exists in all locale files if users see the raw key instead of translated text.","Extend describeProviderError to map the unrecognized error shape to a human-readable message."],"exampleFix":"// before\nthrow new Error(describeProviderError(maybe.error, t(\"app.error_request_failed\")));\n// after\nthrow new Error(describeProviderError(maybe.error, t(\"app.error_request_failed\"), { raw: safeStringify(maybe.error) }));","handlingStrategy":"try-catch","validationCode":"const result = await sendPrompt(payload);\nif (result && \"error\" in result && result.error !== undefined) {\n  handleProviderError(result.error); // inspect before it becomes a generic message\n}","typeGuard":"function hasClientError(r: unknown): r is { error: unknown } {\n  return typeof r === \"object\" && r !== null && \"error\" in r && (r as { error?: unknown }).error !== undefined;\n}","tryCatchPattern":"try {\n  await sendPrompt(payload);\n} catch (e) {\n  if (e instanceof Error && e.message === \"app.error_request_failed\") {\n    logRawProviderError(lastResult.error); // dig out the real cause\n    showToast(\"Provider request failed — check model/API key/quota\");\n    return;\n  }\n  throw e;\n}","preventionTips":["Keep app.error_request_failed defined in every locale file so users never see the raw key.","Extend describeProviderError mappings whenever you add a provider or it returns new error shapes.","Log the raw error payload from the provider alongside the localized message for debuggability.","Pre-flight check API key validity and model availability before sending prompts."],"tags":["i18n","provider","request-failed"],"backgroundTag":"provider-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}