{"record":{"id":"5fdd8cd315452613","repo":"lfnovo/open-notebook","slug":"error-fetching-default-prompt-str-e","errorCode":null,"errorMessage":"Error fetching default prompt: {str(e)}","messagePattern":"Error fetching default prompt: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/transformations.py","lineNumber":155,"sourceCode":"\n\n@router.get(\"/transformations/default-prompt\", response_model=DefaultPromptResponse)\nasync def get_default_prompt():\n    \"\"\"Get the default transformation prompt.\"\"\"\n    try:\n        default_prompts: DefaultPrompts = await DefaultPrompts.get_instance()  # type: ignore[assignment]\n\n        return DefaultPromptResponse(\n            transformation_instructions=default_prompts.transformation_instructions\n            or \"\"\n        )\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error fetching default prompt: {str(e)}\")\n        raise HTTPException(\n            status_code=500, detail=f\"Error fetching default prompt: {str(e)}\"\n        )\n\n\n@router.put(\"/transformations/default-prompt\", response_model=DefaultPromptResponse)\nasync def update_default_prompt(prompt_update: DefaultPromptUpdate):\n    \"\"\"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        )","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/transformations.py#L137-L173","documentation":"Generic 500 from GET /transformations/default-prompt when reading the default transformation prompt (DefaultPrompts) fails unexpectedly. The handler has no logic of its own beyond fetching the default prompt, so the failure is a data/persistence-layer error (SurrealDB query or record deserialization).","triggerScenarios":"GET /api/transformations/default-prompt while SurrealDB is unreachable, the default prompt record is corrupted/has an unexpected shape, or the database schema migration has not run yet.","commonSituations":"SurrealDB not started (make database missing), API started before migrations completed, or a version upgrade changed the default-prompt record layout while old data remained.","solutions":["Confirm SurrealDB is running on port 8000 (make status) and the API could connect at startup","Check API logs for the underlying exception message logged just before the 500","Restart the API so schema migrations run (they run automatically on startup)","If the record is corrupted, inspect/reset the default prompt record in SurrealDB"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"health = await client.get('/health')  # or any cheap endpoint\nif health.status_code != 200:\n    raise RuntimeError('API/database unavailable')","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    resp = await client.get('/transformations/default-prompt')\n    if resp.status_code == 200:\n        break\n    await asyncio.sleep(2 ** attempt)\nelse:\n    raise RuntimeError('default prompt endpoint unavailable')","preventionTips":["Start SurrealDB before the API (make database first)","Let API startup migrations complete before serving traffic","Monitor database connectivity health"],"tags":["fastapi","http-500","default-prompt","surrealdb"],"backgroundTag":"database-query-failed","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}