fix: guard migration meta cleanup against scalar jsonb values#36
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 EBunexpected-quit.log). At least one prodconversations.metais 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
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.🤖 Generated with Claude Code