{"record":{"id":"32542650ccdf1ca2","repo":"srbhr/Resume-Matcher","slug":"data-detail-failed-to-regenerate-content-sta","errorCode":null,"errorMessage":"${data.detail || Failed to regenerate content (status ${res.status}).}","messagePattern":"\\$\\{data\\.detail \\|\\| Failed to regenerate content \\(status \\$\\{res\\.status\\}\\)\\.\\}","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/frontend/lib/api/enrichment.ts","lineNumber":156,"sourceCode":"  subtitle?: string;\n  message: string;\n}\n\nexport interface RegenerateResponse {\n  regenerated_items: RegeneratedItem[];\n  errors?: RegenerateItemError[];\n}\n\n/**\n * Regenerate selected resume items based on user feedback.\n * Uses AI to rewrite content addressing user's concerns.\n */\nexport async function regenerateItems(request: RegenerateRequest): Promise<RegenerateResponse> {\n  const res = await apiPost('/enrichment/regenerate', request);\n\n  if (!res.ok) {\n    const data = await res.json().catch(() => ({}));\n    throw new Error(data.detail || `Failed to regenerate content (status ${res.status}).`);\n  }\n\n  return res.json();\n}\n\n/**\n * Apply regenerated items to the master resume.\n */\nexport async function applyRegeneratedItems(\n  resumeId: string,\n  regeneratedItems: RegeneratedItem[]\n): Promise<{ message: string; updated_items: number }> {\n  const res = await apiPost(`/enrichment/apply-regenerated/${resumeId}`, regeneratedItems);\n\n  if (!res.ok) {\n    const data = await res.json().catch(() => ({}));\n    throw new Error(data.detail || `Failed to apply changes (status ${res.status}).`);\n  }","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/frontend/lib/api/enrichment.ts#L138-L174","documentation":"regenerateItems in apps/frontend/lib/api/enrichment.ts throws this Error when the POST to `/enrichment/regenerate` returns a non-OK HTTP status. It prefers the server JSON `detail` and otherwise reports the status code. It indicates the backend could not regenerate the requested resume content items via the AI service.","triggerScenarios":"apiPost('/enrichment/regenerate', request) returns 401 (session invalid), 422 (RegenerateRequest missing resume_id, items, or feedback fields required by the backend schema), 429 (AI provider rate limit), or 500/504 (LLM regeneration timed out or crashed).","commonSituations":"Frontend sends an older RegenerateRequest shape after the backend contract changed (422); many users regenerate simultaneously hitting provider rate limits (429); long regeneration prompts exceed the LLM timeout (504); auth expired mid-session (401).","solutions":["Inspect res.status and detail: 422 -> align the RegenerateRequest payload with the current API schema; 429 -> back off and retry later; 5xx -> check backend AI provider health.","Validate the request object (resume_id present, items non-empty) before calling regenerateItems.","Implement retry-with-backoff for 429/502/503/504 responses.","Re-authenticate the user on 401 and retry once.","Check backend logs for LLM provider errors (key, quota, model availability)."],"exampleFix":"// before\nconst res = await apiPost('/enrichment/regenerate', request);\nif (!res.ok) {\n  const data = await res.json().catch(() => ({}));\n  throw new Error(data.detail || `Failed to regenerate content (status ${res.status}).`);\n}\n// after\nif (!request.items || request.items.length === 0) {\n  throw new Error('Select at least one item to regenerate.');\n}\nconst res = await apiPost('/enrichment/regenerate', request);\nif (!res.ok) {\n  const data = await res.json().catch(() => ({}));\n  throw new Error(data.detail || `Failed to regenerate content (status ${res.status}).`);\n}","handlingStrategy":"retry","validationCode":"if (!request?.resume_id?.trim() || !Array.isArray(request.items) || request.items.length === 0) {\n  throw new Error('Regenerate requires a resume_id and at least one item.');\n}","typeGuard":"function isRegenerateRequest(r: unknown): r is RegenerateRequest {\n  return typeof r === 'object' && r !== null && 'resume_id' in r &&\n    Array.isArray((r as RegenerateRequest).items) && (r as RegenerateRequest).items.length > 0;\n}","tryCatchPattern":"async function regenerateWithRetry(request: RegenerateRequest, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    try { return await regenerateItems(request); }\n    catch (e) {\n      const msg = e instanceof Error ? e.message : '';\n      const retryable = /status (429|502|503|504)/.test(msg);\n      if (!retryable || i === attempts - 1) throw e;\n      await new Promise(r => setTimeout(r, 2 ** i * 500));\n    }\n  }\n  throw new Error('unreachable');\n}","preventionTips":["Validate the RegenerateRequest shape against the current API schema before calling.","Retry only 429/5xx statuses with exponential backoff; fail fast on 4xx.","Monitor AI provider quota/latency server-side to reduce regeneration failures."],"tags":["http-error","fetch","ai","api-client"],"backgroundTag":"http-non-ok-response","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}