Skip to content

fix: guard migration meta cleanup against scalar jsonb values#36

Merged
1xabhay merged 1 commit into
mainfrom
fix/migration-scalar-meta-guard
Jun 11, 2026
Merged

fix: guard migration meta cleanup against scalar jsonb values#36
1xabhay merged 1 commit into
mainfrom
fix/migration-scalar-meta-guard

Conversation

@1xabhay

@1xabhay 1xabhay commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What happened

The #35 deploy failed on prod: the migration's meta-strip UPDATE crashed with asyncpg.exceptions.InvalidParameterValueError: cannot delete from scalar (full traceback in EB unexpected-quit.log). At least one prod conversations.meta is a bare JSON scalar, and the jsonb - operator only works on objects. The migration runs in a single transaction, so prod's schema/data were untouched; the environment was rolled back to 983ef96 and is serving (health 200).

Fix

Add AND jsonb_typeof(meta) = 'object' to the UPDATE. Scalar meta rows can't contain the prompt keys, so skipping them is correct.

Verification

  • Reproduced the exact error locally against a seeded scalar-meta row.
  • Downgraded to d740e0090bdc, seeded two open conversations with scalar meta (string and number), upgraded with the fix: merge collapsed them into one keeper, scalar meta passed through untouched, migration completed.
  • 189 tests pass (conftest runs the full migration chain from scratch).

🤖 Generated with Claude Code

The meta-strip UPDATE in 9228797f839a crashed on prod with
"cannot delete from scalar": at least one conversations.meta holds a bare
JSON scalar, and the jsonb `-` operator only works on objects. The aborted
deploy left the migration rolled back (single transaction), so re-running
the guarded version is safe. Scalar meta rows can't contain the prompt keys
anyway, so skipping them is correct.

Verified locally by downgrading to d740e0090bdc, seeding open conversations
with scalar meta (string and number), and upgrading: merge collapses them,
scalar values pass through untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@1xabhay 1xabhay merged commit 0580188 into main Jun 11, 2026
1 check passed
@1xabhay 1xabhay deleted the fix/migration-scalar-meta-guard branch June 11, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant