srbhr/Resume-Matcher · error · Error
${data.detail || Failed to apply changes (status ${res.statu
Error message
${data.detail || Failed to apply changes (status ${res.status}).} What it means
applyRegeneratedItems in apps/frontend/lib/api/enrichment.ts throws this Error when the POST to `/enrichment/apply-regenerated/{resumeId}` returns a non-OK response. It surfaces the backend `detail` message or a generic status-embedded message. It means the server could not persist the regenerated items back onto the resume.
Source
Thrown at apps/frontend/lib/api/enrichment.ts:173
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}).`);
}
return res.json();
}
View on GitHub (pinned to 116f9cc3b0)
Solutions
- Check res.status to distinguish auth (401), missing resume (404), payload (422), and server (5xx) causes.
- Guard against applying an empty regeneratedItems array client-side before calling.
- On 404, refresh the resume list and tell the user the resume no longer exists.
- On 401, prompt re-login and retry the apply once.
- Inspect backend logs for persistence errors on 5xx and verify DB connectivity.
Example fix
// before
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}).`);
}
// after
if (regeneratedItems.length === 0) {
throw new Error('There are no regenerated changes to apply.');
}
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}).`);
} Defensive patterns
Strategy: validation
Validate before calling
if (!resumeId?.trim()) throw new Error('resumeId is required to apply regenerated items.');
if (!Array.isArray(regeneratedItems) || regeneratedItems.length === 0) {
throw new Error('No regenerated items to apply.');
} Type guard
function isRegeneratedItemList(v: unknown): v is RegeneratedItem[] {
return Array.isArray(v) && v.length > 0 && v.every(x =>
typeof x === 'object' && x !== null && 'id' in x && 'content' in x);
} Try / catch
try {
const { updated_items } = await applyRegeneratedItems(resumeId, regeneratedItems);
} catch (e) {
const msg = e instanceof Error ? e.message : '';
if (msg.includes('status 404')) showError('Resume not found — it may have been deleted.');
else if (msg.includes('status 401')) redirectToLogin();
else showError('Could not save regenerated changes. Please retry.');
} Prevention
- Guard against empty regeneratedItems arrays before calling apply.
- Confirm resume existence before long enrichment flows if deletions elsewhere are possible.
- Show a clean message instead of leaking raw backend detail strings to end users.
When it happens
Trigger: apiPost(`/enrichment/apply-regenerated/${resumeId}`, regeneratedItems) resolves non-OK: 401 unauthenticated, 404 resumeId missing, 422 regeneratedItems is an empty array or items lack required fields (id, content) per the backend schema, or 5xx on the database write.
Common situations: User accepts changes after regenerating, but the resume was deleted in another tab (404); the regenerated items array is empty because all regeneration failed upstream (422); auth cookie expired between generate and apply (401); DB constraint/lock failure on the backend (500).
Related errors
- ${data.detail || Failed to apply enhancements (status ${res.
- ${data.detail || Failed to analyze resume (status ${res.stat
- ${data.detail || Failed to generate enhancements (status ${r
- ${data.detail || Failed to regenerate content (status ${res.
- ${text || Resume wizard turn failed with status ${response.s
AI-assisted analysis of srbhr/Resume-Matcher@116f9cc3b0 (2026-08-28).
Data as JSON: /api/errors/6c3060cba1bfa139.
Report an issue: GitHub.