You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
prisma_cmd.rs migration-name slice panics with out-of-bounds index when token is short and line-final #3445
Split off from #2954 (per @HetCreep's audit at v0.44.2), same session as #3444 — a different failure mode than the byte-boundary family: an out-of-bounds slice rather than a mid-character one.
src/cmds/js/prisma_cmd.rs:319-321:
let end = line[pos..].find(|c:char| c.is_whitespace()).unwrap_or(20);
latest_migration = line[pos..pos + end].to_string();
When the 202… migration token is the last thing on the line (no trailing whitespace to find) and shorter than 20 bytes, .unwrap_or(20) hands back a fixed length that overruns the actual remaining string, and pos + end slices past the end.
Note prisma_cmd.rs:252, ~60 lines earlier in the same file, already has the correct fallback: .unwrap_or(line.len() - pos). Line 319 just didn't get the same fix.
Live repro:
fnprisma_slice(line:&str) -> String{let pos = line.find("202").unwrap();let end = line[pos..].find(|c:char| c.is_whitespace()).unwrap_or(20);
line[pos..pos + end].to_string()}fnmain(){let line = "applied 20240115_x";// token from pos to end-of-line is 11 bytes, no trailing whitespaceprintln!("{}", prisma_slice(line));}
thread 'main' panicked at repro.rs:8:9:
end byte index 28 is out of bounds for string of length 18
Confirmed exit code 101, matches current develop (3044911).
Suggested fix: mirror line 252's fallback:
let end = line[pos..].find(|c:char| c.is_whitespace()).unwrap_or(line.len() - pos);
(Credit: @HetCreep's source audit on #2954 first flagged this while confirming the original issue was fixed — filing separately per their suggestion since it's a distinct call site/bug from the original report.)
prisma_cmd.rs:319-321 slices with a fixed unwrap_or(20) fallback that overruns short, line-final migration tokens, panicking on out-of-bounds index — fix by mirroring line 252's unwrap_or(line.len() - pos).
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
src/cmds/js/prisma_cmd.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Fixed by #3836, shipped in v0.50.0: the migration id is now sliced to the end of the line instead of a fixed 20 bytes. rtk prisma migrate status on output ending with applied 20240115_x no longer panics. Please reopen or comment if you still see this on the latest release.
Activity
pszymkowiak commentedon Aug 5, 2026
🔍 Automated Triage
bugmediumSummary
prisma_cmd.rs:319-321 slices with a fixed unwrap_or(20) fallback that overruns short, line-final migration tokens, panicking on out-of-bounds index — fix by mirroring line 252's unwrap_or(line.len() - pos).
📁 Relevant files
src/cmds/js/prisma_cmd.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
KuSh commentedon Nov 23, 2026
Fixed by #3836, shipped in v0.50.0: the migration id is now sliced to the end of the line instead of a fixed 20 bytes.
rtk prisma migrate statuson output ending withapplied 20240115_xno longer panics. Please reopen or comment if you still see this on the latest release.