srbhr/Resume-Matcher · error · Error
${data.detail || Failed to regenerate content (status ${res.
Error message
${data.detail || Failed to regenerate content (status ${res.status}).} What it means
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.
Source
Thrown at apps/frontend/lib/api/enrichment.ts:156
subtitle?: string;
message: string;
}
export interface RegenerateResponse {
regenerated_items: RegeneratedItem[];
errors?: RegenerateItemError[];
}
/**
* Regenerate selected resume items based on user feedback.
* Uses AI to rewrite content addressing user's concerns.
*/
export async function regenerateItems(request: RegenerateRequest): Promise<RegenerateResponse> {
const res = await apiPost('/enrichment/regenerate', request);
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.detail || `Failed to regenerate content (status ${res.status}).`);
}
return res.json();
}
/**
* Apply regenerated items to the master resume.
*/
export async function applyRegeneratedItems(
resumeId: string,
regeneratedItems: RegeneratedItem[]
): Promise<{ message: string; updated_items: number }> {
const res = await apiPost(`/enrichment/apply-regenerated/${resumeId}`, regeneratedItems);
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.detail || `Failed to apply changes (status ${res.status}).`);
}View on GitHub (pinned to 116f9cc3b0)
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).
Example fix
// before
const res = await apiPost('/enrichment/regenerate', request);
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.detail || `Failed to regenerate content (status ${res.status}).`);
}
// after
if (!request.items || request.items.length === 0) {
throw new Error('Select at least one item to regenerate.');
}
const res = await apiPost('/enrichment/regenerate', request);
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.detail || `Failed to regenerate content (status ${res.status}).`);
} Defensive patterns
Strategy: retry
Validate before calling
if (!request?.resume_id?.trim() || !Array.isArray(request.items) || request.items.length === 0) {
throw new Error('Regenerate requires a resume_id and at least one item.');
} Type guard
function isRegenerateRequest(r: unknown): r is RegenerateRequest {
return typeof r === 'object' && r !== null && 'resume_id' in r &&
Array.isArray((r as RegenerateRequest).items) && (r as RegenerateRequest).items.length > 0;
} Try / catch
async function regenerateWithRetry(request: RegenerateRequest, attempts = 3) {
for (let i = 0; i < attempts; i++) {
try { return await regenerateItems(request); }
catch (e) {
const msg = e instanceof Error ? e.message : '';
const retryable = /status (429|502|503|504)/.test(msg);
if (!retryable || i === attempts - 1) throw e;
await new Promise(r => setTimeout(r, 2 ** i * 500));
}
}
throw new Error('unreachable');
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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).
Related errors
- ${text || Resume wizard turn failed with status ${response.s
- ${text || Resume wizard finalize failed with status ${respon
- Improve failed with status ${response.status}: ${text}
- ${data.detail || Failed to analyze resume (status ${res.stat
- ${data.detail || Failed to generate enhancements (status ${r
AI-assisted analysis of srbhr/Resume-Matcher@116f9cc3b0 (2026-08-28).
Data as JSON: /api/errors/32542650ccdf1ca2.
Report an issue: GitHub.