lfnovo/open-notebook · error · HTTPException

Error updating transformation: {str(e)}

Error message

Error updating transformation: {str(e)}

What it means

Generic 500 from PUT /transformations/{transformation_id} when saving or serializing the updated record fails with an unexpected exception. Distinct from the 400 (validation) and 404 (missing record/model) paths; this indicates persistence or internal errors.

Source

Thrown at api/routers/transformations.py:249

            # Validate a newly supplied model reference (allow clearing to None).
            if transformation_update.model_id:
                model = await Model.get(transformation_update.model_id)
                if not model:
                    raise HTTPException(status_code=404, detail="Model not found")
            transformation.model_id = transformation_update.model_id

        await transformation.save()

        return _transformation_response(transformation)
    except HTTPException:
        raise
    except InvalidInputError as e:
        raise HTTPException(status_code=400, detail=str(e))
    except OpenNotebookError:
        raise
    except Exception as e:
        logger.error(f"Error updating transformation {transformation_id}: {str(e)}")
        raise HTTPException(
            status_code=500, detail=f"Error updating transformation: {str(e)}"
        )


@router.delete("/transformations/{transformation_id}")
async def delete_transformation(transformation_id: str):
    """Delete a transformation."""
    try:
        transformation = await Transformation.get(transformation_id)
        if not transformation:
            raise HTTPException(status_code=404, detail="Transformation not found")

        await transformation.delete()

        return {"message": "Transformation deleted successfully"}
    except HTTPException:
        raise
    except OpenNotebookError:

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Check API logs for the exact exception message logged before the 500
  2. Confirm SurrealDB is running and responsive
  3. Re-fetch the transformation and re-apply your changes to avoid stale-state conflicts
  4. Restart the API so automatic schema migrations execute
Defensive patterns

Strategy: retry

Validate before calling

assert (await client.get(f'/transformations/{tid}')).status_code == 200, 'record missing or DB unhealthy'

Try / catch

resp = await client.put(f'/transformations/{tid}', json=patch)
if resp.status_code >= 500:
    await asyncio.sleep(2)
    resp = await client.put(f'/transformations/{tid}', json=patch)
resp.raise_for_status()

Prevention

When it happens

Trigger: PUT with valid fields while SurrealDB is unavailable, the save conflicts with a concurrent writer, or the response serialization hits an unexpected attribute.

Common situations: Database outage mid-request, concurrent edits to the same transformation, or stale DB schema after upgrading Open Notebook without letting migrations run.

Related errors


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