Repository navigation
fix(prisma): stop migrate status panicking on a trailing migration id - #3836
Merged
Merged
Conversation
`filter_migrate_status` looked for whitespace after the `202...` id and fell
back to a hardcoded 20 bytes when there was none -- so an id that runs to the
end of the line slices past it:
Migration could not be applied at 2024-01-01T12:00:00
len 53, pos 34, end 20 -> line[34..54] -> end byte index 54 is out of bounds
Release builds set `panic = "abort"`, so `rtk prisma migrate status` dies and
the user loses the command output entirely -- the one thing a filter must never
do. A multibyte character straddling that offset panics the same way, on the
char boundary instead.
The fallback is the rest of the line, which is what the sibling
`filter_migrate_dev` has always used 70 lines above.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Merged
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.
Problem
filter_migrate_status(src/cmds/js/prisma_cmd.rs) finds the202…migration id, looks for the whitespace that ends it, and falls back to a hardcoded 20 bytes when there is none:When the id runs to the end of the line there is no whitespace, so the slice runs past it:
Release builds set
panic = "abort"(Cargo.toml), sortk prisma migrate statusdies outright and the user loses the command's output — the failure mode.claude/rules/rust-patterns.mdsingles out ("If filter fails, execute raw command unchanged. Never block the user").A multibyte character straddling
pos + 20panics the same way, as a char-boundary error instead.Fix
Fall back to the rest of the line, which is what the sibling
filter_migrate_devhas always done 70 lines above:That bound is char-safe by construction:
line.len() - posis exactly the length of theline[pos..]slice.Test plan
filter_migrate_statushad no test at all (onlytest_filter_migrate_devexisted). Added one covering both shapes — an id at end of line, and a multibyte character right after it — and verified it panics atprisma_cmd.rs:320with the old fallback restored, then passes with the fix.cargo fmt --all && cargo clippy --all-targets && cargo test --allclean.Found by a review round while working on another PR; unrelated to that work, so it is on its own branch off
develop.🤖 Generated with Claude Code