Bug: question-notebook upsert with base64 images fails with OperationalError: 22 values for 23 columns
Environment
- DeepTutor v1.6.4 (ghcr.io/hkuds/deeptutor:latest)
Reproduction
POST /api/question-notebook/entries/upsert with a non-null user_answer_images field (base64 image) returns HTTP 500:
{"detail":"OperationalError: 22 values for 23 columns","type":"OperationalError"}
The same payload with user_answer_images: null succeeds (entry created). Looks like the INSERT into the images/attachments table passes one fewer value than the column count — likely a missing column in the SQL statement (e.g. a created_at/owner/scope column not included in the values list).
Workaround
Retry the upsert without images (entries save fine, images lost).
Reproducible against any session; happened with both JPEG and PNG base64 payloads.
Hi, I'd like to work on this. I reproduced the failure on current dev (269f65d). The image-specific INSERT lists 23 columns but supplies only 22 SQL values: it is missing the resolved placeholder before the literal bookmarked/followup_session_id values, although the bound tuple already provides the resolved value.
I'll submit a focused fix plus an API regression test that upserts a base64 image and verifies the persisted image metadata. Disclosure: I'm using AI assistance, and I will manually review and run the tests before submitting.
Thanks for your comments!Will be fixed in the next version~
Fixed on dev in #1258. The root cause was one missing placeholder — the images branch listed 23 columns against 22 values — so both INSERT branches are now 23/23. ai_judgment was not the missing piece; it already has a DEFAULT in the schema.