fix(presets): set-priority repairs corrupted boolean priority#3269
Open
jawwad-ali wants to merge 1 commit into
Open
fix(presets): set-priority repairs corrupted boolean priority#3269jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
Same bool-is-int trap as the extension set-priority command: the skip guard 'isinstance(raw_priority, int) and raw_priority == priority' treats a stored boolean as a match (isinstance(True, int) is True, True == 1), so a corrupted boolean priority reports 'already has priority N' and is never rewritten to a real int — contradicting the adjacent comment. Exclude bools explicitly, mirroring normalize_priority's bool guard. Co-Authored-By: Claude Opus 4.8 <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.
Description
preset set-prioritycarries the same bool-is-int trap asextension set-priority. The skip-if-unchanged guard, whose comment promises corrupted values are repaired:matches a corrupted boolean priority, because
isinstance(True, int)isTrueandTrue == 1(False == 0). Runningpreset set-priority <pack> 1on a pack whose priority is corrupted toTruereports "already has priority 1" and exits without repairing it.normalize_priority()already excludes bools; this call site didn't.Fix
Exclude bools from the skip guard, mirroring
normalize_priority(and the matching extension-side fix):Testing
test_set_priority_repairs_corrupted_bool: injectspriority: True, runspreset set-priority test-pack 1, asserts it reports priority changed (not already has priority) and the reloaded value is1withnot isinstance(..., bool). Fails before ("already has priority 1", verified by source-stash), passes after.TestPresetSetPrioritypasses (5 tests);uvx ruff checkclean. The same-value test (priority 5) stays green.AI Disclosure
Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI flagged the same bool-is-int trap on the preset side; I confirmed it on an independent code path, proved fail-before via source-stash, and reviewed the diff before submitting.