{"record":{"id":"40774c1bfceb9864","repo":"bytedance/deer-flow","slug":"failed-to-update-user-profile-str-e","errorCode":null,"errorMessage":"Failed to update user profile: {str(e)}","messagePattern":"Failed to update user profile: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/app/gateway/routers/agents.py","lineNumber":529,"sourceCode":"    \"\"\"Create or overwrite the global USER.md.\n\n    Args:\n        request: The update request with the new USER.md content.\n\n    Returns:\n        UserProfileResponse with the saved content.\n    \"\"\"\n    _require_agents_api_enabled()\n\n    try:\n        paths = get_paths()\n        paths.base_dir.mkdir(parents=True, exist_ok=True)\n        paths.user_md_file.write_text(request.content, encoding=\"utf-8\")\n        logger.info(f\"Updated USER.md at {paths.user_md_file}\")\n        return UserProfileResponse(content=request.content or None)\n    except Exception as e:\n        logger.error(f\"Failed to update user profile: {e}\", exc_info=True)\n        raise HTTPException(status_code=500, detail=f\"Failed to update user profile: {str(e)}\")\n\n\n@router.delete(\n    \"/agents/{name}\",\n    status_code=204,\n    summary=\"Delete Custom Agent\",\n    description=\"Delete a custom agent and all its files (config, SOUL.md, memory).\",\n)\nasync def delete_agent(name: str) -> None:\n    \"\"\"Delete a custom agent.\n\n    Args:\n        name: The agent name.\n\n    Raises:\n        HTTPException: 404 if no per-user copy exists; 409 if only a legacy\n            shared copy exists (suggesting the migration script).\n    \"\"\"","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/agents.py#L511-L547","documentation":"Catch-all 500 on PUT `/user-profile`: writing USER.md failed. The handler mkdirs `paths.base_dir` then `write_text`s the content; failures are permission errors creating/writing the directory, disk full, or read-only mounts. Unlike reads, no graceful path exists — a failed write is always a 500 with the cause logged.","triggerScenarios":"base_dir on a read-only volume; Gateway process lacking write permission on the data dir; ENOSPC; SELinux denying writes.","commonSituations":"Hardened container deployments with immutable config mounts; first write after a permissions migration; disk-full incidents.","solutions":["Confirm the Gateway process user can create and write under base_dir (`sudo -u <user> touch <base_dir>/probe`)","Mount the profile directory writable, or relocate base_dir to writable storage","Free disk space / adjust SELinux or AppArmor policy as the traceback indicates"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return await api.updateUserProfile(content); }\ncatch (e) {\n  if (e.status === 500 && /update user profile/.test(e.detail)) {\n    toast('Could not save profile — server storage is not writable');\n    keepLocalDraft(content); // don't lose the user's text\n    return;\n  }\n  throw e;\n}","preventionTips":["Verify the base_dir volume is writable by the Gateway user at deploy time","Keep a local draft of profile edits until the save confirms","Disk-full and read-only mounts are the two most common root causes — check both"],"tags":["http-500","user-profile","permissions","filesystem"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}