Fix inline snapshot corruption on multiline accept + partial accept workflow tests#494
Merged
MatthewMckee4 merged 3 commits intomainfrom Feb 22, 2026
Merged
Conversation
Test coverage for partially accepting inline snapshots across multiple review sessions, including multiline values that shift source line numbers. - Accept first/skip second, then review again to accept second - Accept first/skip second, re-run tests, then accept remaining - Multiline accept shifts line numbers; stale line number still resolves - Multiline accept + re-run creates duplicate pending snapshots at old/new lines
Merging this PR will not alter performance
|
find_inline_argument searched forward from a stale line number for the first assert_snapshot call, which could land on an intervening function's inline argument and corrupt it. Now accepts an optional function_name parameter and skips calls in wrong functions. Adds containing_function_name helper and 6 new tests (2 integration, 4 unit) that verify the fix.
Strip inline comments that just narrate what the code does (e.g., "// Review: accept first, skip second"). Keep only comments that explain non-obvious intent. Add CLAUDE.md rule against useless inline comments in tests.
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.
Summary
find_inline_argumentwhere a multiline inline accept that shifts line numbers could corrupt an intervening function'sinline=argumentcontaining_function_namehelper andfunction_nameparameter tofind_inline_argument/rewrite_inline_snapshotto match the correctassert_snapshotcallBug
When accepting a multiline inline snapshot, the source file expands (e.g.,
inline=""becomes a triple-quoted block adding ~4 lines). Subsequent.snap.newfiles have stale line numbers.find_inline_argumentsearched forward from the stale line for the firstassert_snapshot(call, which could land on an intervening function'sinline=argument and silently corrupt it.Fix
find_inline_argumentnow accepts an optionalfunction_nameparameter. When provided, it usescontaining_function_nameto verify the found call is inside the correct function, skipping calls in wrong functions.Test plan
prek run -apasses clean