lfnovo/open-notebook · error · HTTPException

Error fetching default prompt: {str(e)}

Error message

Error fetching default prompt: {str(e)}

What it means

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).

Source

Thrown at api/routers/transformations.py:155


@router.get("/transformations/default-prompt", response_model=DefaultPromptResponse)
async def get_default_prompt():
    """Get the default transformation prompt."""
    try:
        default_prompts: DefaultPrompts = await DefaultPrompts.get_instance()  # type: ignore[assignment]

        return DefaultPromptResponse(
            transformation_instructions=default_prompts.transformation_instructions
            or ""
        )
    except HTTPException:
        raise
    except OpenNotebookError:
        raise
    except Exception as e:
        logger.error(f"Error fetching default prompt: {str(e)}")
        raise HTTPException(
            status_code=500, detail=f"Error fetching default prompt: {str(e)}"
        )


@router.put("/transformations/default-prompt", response_model=DefaultPromptResponse)
async def update_default_prompt(prompt_update: DefaultPromptUpdate):
    """Update the default transformation prompt."""
    try:
        default_prompts: DefaultPrompts = await DefaultPrompts.get_instance()  # type: ignore[assignment]

        default_prompts.transformation_instructions = (
            prompt_update.transformation_instructions
        )
        await default_prompts.update()

        return DefaultPromptResponse(
            transformation_instructions=default_prompts.transformation_instructions
        )

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Confirm SurrealDB is running on port 8000 (make status) and the API could connect at startup
  2. Check API logs for the underlying exception message logged just before the 500
  3. Restart the API so schema migrations run (they run automatically on startup)
  4. If the record is corrupted, inspect/reset the default prompt record in SurrealDB
Defensive patterns

Strategy: retry

Validate before calling

health = await client.get('/health')  # or any cheap endpoint
if health.status_code != 200:
    raise RuntimeError('API/database unavailable')

Try / catch

for attempt in range(3):
    resp = await client.get('/transformations/default-prompt')
    if resp.status_code == 200:
        break
    await asyncio.sleep(2 ** attempt)
else:
    raise RuntimeError('default prompt endpoint unavailable')

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27). Data as JSON: /api/errors/5fdd8cd315452613. Report an issue: GitHub.