fix(migrate): under() panics when a trigger length splits a multi-byte char - #166
Open
charlesdove977 wants to merge 1 commit into
Open
charlesdove977 wants to merge 1 commit into
charlesdove977 wants to merge 1 commit into
Conversation
…te char under() byte-sliced rel[..dir.len()]. When a markdown path holds a multi-byte char (e.g. an Obsidian note named "a → b.md") at the byte offset equal to a trigger's length, the slice is not a char boundary and the whole process panics. That panic surfaces as a SessionStart hook error on every session in any workspace holding such a file. Use str::get, which returns None off a char boundary: a split char means the prefix cannot match anyway, so it is a miss, not a crash. Adds a regression assert that panicked at migrate.rs:704 before. Co-Authored-By: Claude Opus 5 (1M context) <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.
@ChristopherKahler heads up, this one takes down the SessionStart hook for any workspace that has a markdown file with a multi-byte char in its path.
Bug
base hook session-startpanics on 0.15.1 and 0.15.2 (and currentmain):under()byte-slicesrel[..dir.len()]. When a path likegraphify-out/obsidian/Auto-reply → engagement → algorithm boost.md(graphify's Obsidian export names notes this way) has a multi-byte char straddling the byte offset equal to a trigger's length, the slice panics and the whole hook exits 101. Claude Code shows it asSessionStart:startup hook errorevery session.Fix
rel.get(..dir.len()).is_some_and(|head| head.eq_ignore_ascii_case(dir)).getreturnsNoneoff a char boundary; a split char means the prefix can't match anyway, so it's a miss instead of a crash. Behavior on every valid boundary is unchanged.Verification
!under("notes/a → b.md", "notes/a x")inunder_is_a_path_test_not_a_string_prefix: panics atmigrate.rs:704without the fix, passes with it.base hook session-startin the affected workspace with exit 0.cargo test: 556 pass.graph::tests::purge_apply_deletes_unread_spares_recent_and_snapshotsandpurge_dry_run_selects_by_recency_and_writes_nothingfail identically on unmodifiedmainlocally, so they're unrelated to this change.🤖 Generated with Claude Code