{"record":{"id":"2bd4b5c33fe562fa","repo":"lfnovo/open-notebook","slug":"error-updating-default-prompt-str-e","errorCode":null,"errorMessage":"Error updating default prompt: {str(e)}","messagePattern":"Error updating default prompt: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/transformations.py","lineNumber":180,"sourceCode":"    \"\"\"Update the default transformation prompt.\"\"\"\n    try:\n        default_prompts: DefaultPrompts = await DefaultPrompts.get_instance()  # type: ignore[assignment]\n\n        default_prompts.transformation_instructions = (\n            prompt_update.transformation_instructions\n        )\n        await default_prompts.update()\n\n        return DefaultPromptResponse(\n            transformation_instructions=default_prompts.transformation_instructions\n        )\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error updating default prompt: {str(e)}\")\n        raise HTTPException(\n            status_code=500, detail=f\"Error updating default prompt: {str(e)}\"\n        )\n\n\n@router.get(\n    \"/transformations/{transformation_id}\", response_model=TransformationResponse\n)\nasync def get_transformation(transformation_id: str):\n    \"\"\"Get a specific transformation by ID.\"\"\"\n    try:\n        transformation = await Transformation.get(transformation_id)\n        if not transformation:\n            raise HTTPException(status_code=404, detail=\"Transformation not found\")\n\n        return _transformation_response(transformation)\n    except HTTPException:\n        raise\n    except OpenNotebookError:","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/transformations.py#L162-L198","documentation":"Generic 500 from PUT /transformations/default-prompt when persisting the updated default prompt fails unexpectedly. Validation of the request body is done by Pydantic before the handler runs, so a 500 indicates a persistence or serialization failure when saving DefaultPrompts.","triggerScenarios":"PUT /api/transformations/default-prompt with a valid body while SurrealDB is down, the default-prompt record cannot be found/created, or the save raises a non-OpenNotebookError exception.","commonSituations":"Database connectivity loss between GET and PUT, write permission issues on SurrealDB, or schema drift after an upgrade.","solutions":["Check API logs for the exact exception logged before the 500","Verify SurrealDB connectivity and that GET /transformations/default-prompt also works","Retry the PUT after confirming the database is healthy","If persistent, inspect the default prompt record in SurrealDB for corruption"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"current = await client.get('/transformations/default-prompt')\nif current.status_code != 200:\n    raise RuntimeError('cannot read default prompt; DB likely unhealthy')","typeGuard":null,"tryCatchPattern":"resp = await client.put('/transformations/default-prompt', json=body)\nif resp.status_code >= 500:\n    await asyncio.sleep(2)\n    resp = await client.put('/transformations/default-prompt', json=body)\nresp.raise_for_status()","preventionTips":["Read before write — confirm GET works before PUT","Keep request bodies within DefaultPromptUpdate's expected schema","Ensure database availability during writes"],"tags":["fastapi","http-500","default-prompt","surrealdb","write-failure"],"backgroundTag":"database-write-failed","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}