Fix NameError on explicit --trim-5 value (mageck2-doc#1)#6
Merged
Conversation
mageckcount_trim5_auto logged an undefined name 'candidate_trim5' right after parsing a numeric --trim-5, so any explicit (non-auto) --trim-5 crashed with NameError before reading any reads. Log the parsed value 'trim_5_provided' instead. Adds a regression test driving the explicit --trim-5 path. Fixes davidliwei/mageck2-doc#1. 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.
Problem
Reported in mageck2-doc#1 (Nov 2023). Running
mageck2 countwith an explicit numeric--trim-5(e.g.--trim-5 20) crashes:In
mageckcount_trim5_auto, the value is parsed intotrim_5_provided, but the very next log line referencedcandidate_trim5, which is never defined in that function. The crash happens before any reads are processed, so it affects every explicit--trim-5run. (The--trim-5 autodefault takes a different branch, which is why it went unnoticed.)Fix
Log
trim_5_provided(the value that was just parsed) — a one-line change.Test
Adds
test_explicit_trim5_does_not_crashdriving the explicit--trim-5path. Verified it fails with the originalNameErroron the unfixed code and passes with the fix; full suite is green locally (5 passed).Closes davidliwei/mageck2-doc#1.