{"record":{"id":"f557db26137182f5","repo":"srbhr/Resume-Matcher","slug":"failed-to-save-changes-please-try-again","errorCode":null,"errorMessage":"Failed to save changes. Please try again.","messagePattern":"Failed to save changes\\. Please try again\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"apps/backend/app/routers/enrichment.py","lineNumber":801,"sourceCode":"            detail=(\n                \"Resume content changed or could not be uniquely matched. \"\n                \"Please regenerate and try again.\"\n            ),\n        )\n\n    # Update the resume in database\n    updated_content = json.dumps(updated_data, indent=2)\n    try:\n        await db.update_resume(\n            resume_id,\n            {\n                \"content\": updated_content,\n                \"processed_data\": updated_data,\n            },\n        )\n    except Exception as e:\n        logger.error(f\"Failed to save regenerated content to database: {e}\")\n        raise HTTPException(\n            status_code=500,\n            detail=\"Failed to save changes. Please try again.\",\n        )\n\n    return {\n        \"message\": \"Changes applied successfully\",\n        \"updated_items\": len(regenerated_items),\n    }\n","sourceCodeStart":783,"sourceCodeEnd":810,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/backend/app/routers/enrichment.py#L783-L810","documentation":"A 500 raised by apply_regenerated_items when saving the merged regenerated content to the database throws an unexpected exception. The error is logged server-side with the underlying exception; the client only sees a generic save-failure message.","triggerScenarios":"Database connection failure or timeout during the resume update write; a schema/validation error in updated_content or processed_data rejected by the DB layer; any exception raised inside the update call after items were matched.","commonSituations":"DB pool exhausted or Postgres restarted; processed_data grew past a size limit; a migration changed the resumes table so the update payload no longer fits the schema.","solutions":["Retry the apply request — the failure may be transient (check server logs for the underlying exception)","Verify database connectivity and that the resumes table schema accepts the updated fields","Inspect server logs for 'Failed to save regenerated content to database' to find the real exception","If schema-related, fix the payload shape or run the pending migration"],"exampleFix":"// before: blind retry loop\nawait applyRegenerated(resumeId, items);\n// after: retry transient failures with backoff\ntry {\n  await applyRegenerated(resumeId, items);\n} catch (e) {\n  if (e.response?.status === 500) await sleep(1000); // then retry once\n  else throw e;\n}","handlingStrategy":"retry","validationCode":"// Nothing to pre-validate (server-side save failure); ensure payload size is sane before sending\nif (JSON.stringify(payload).length > 1_000_000) throw new Error('Payload too large');","typeGuard":null,"tryCatchPattern":"try {\n  await api.post(`/enrichment/${resumeId}/apply-regenerated`, payload);\n} catch (e) {\n  if (e.response?.status === 500) {\n    await retryWithBackoff(() => api.post(`/enrichment/${resumeId}/apply-regenerated`, payload), { retries: 2 });\n  } else throw e;\n}","preventionTips":["Check server logs for the underlying DB exception before assuming a client bug","Retry transient 500s with exponential backoff and jitter","Keep processed_data within DB size limits","Monitor DB health/pool saturation during enrichment operations"],"tags":["http","database","internal-server-error","fastapi"],"backgroundTag":"database-write-failed","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}