fix: reject duplicate if-block conditions within the same list key - #155
Open
Tobias-Fischer wants to merge 1 commit into
Open
fix: reject duplicate if-block conditions within the same list key#155Tobias-Fischer wants to merge 1 commit into
Tobias-Fischer wants to merge 1 commit into
Conversation
Two "- if:" blocks for the same condition under one list key (e.g. two separate "if: win" blocks in packages_select_by_deps) are never wrong on their own, but they're a standing foot-gun downstream: a future addition can land in the "wrong" one by accident, nothing merges the two, and the same package can end up skipped from one angle and not the other depending on which block someone edits later. This showed up for real across all three of RoboStack's humble/jazzy/ rolling vinca.yaml files -- humble alone had accumulated 4 separate duplicate-condition groups across ~19 blocks (mostly "if: not win" and "if: linux") from being extended incrementally across many sessions, none of which the previous adjacent-block fix (RoboStack#152) would have caught since they weren't adjacent. Raises DuplicateConditionError (exit 1, clean message naming the list key and condition) rather than silently merging the blocks -- merging correctly needs a human to reconcile any per-item comments, since sorting the merged then: list can separate a standalone comment from the item it was meant to describe (the exact hazard RoboStack#152 fixed for adjacent blocks, but which still applies to a comment sitting above an item inside either of the two blocks being merged by hand). Co-Authored-By: Claude Sonnet 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.
Summary
packages_select_by_deps) are never wrong on their own, but they're a standing foot-gun downstream: a future addition can land in the "wrong" one by accident, nothing merges the two, and the same package can end up skipped from one angle and not the other depending on which block someone edits later.- if:line" logic never sees them as related at all.DuplicateConditionError(exit 1, clean message naming the list key and condition) rather than silently merging the blocks — merging correctly needs a human to reconcile any per-item comments, since sorting the mergedthen:list can separate a standalone comment from the item it was meant to describe.Motivation
Found while auditing RoboStack/ros-humble, ros-jazzy, and ros-rolling's
vinca.yamlfiles for exactly this pattern. Humble alone had accumulated 4 separate duplicate-condition groups across ~19 blocks (mostlyif: not winandif: linux) from being extended incrementally across many sessions — consolidating them by hand also surfaced live cases where a per-item comment had already drifted onto the wrong package from a previous sort, which is what motivated making the check hard-fail rather than silently reformat.Test plan
pytest vinca/— all 236 tests pass (7 intest_sort_vinca_lists.py, including 3 new ones for this change: duplicate-in-same-list raises, duplicate-across-different-list-keys is fine, different-conditions-in-same-list is fine)ruff check/ruff format --checkcleanvinca.yamlfiles — all pass clean with no duplicates- if: win... other content ...- if: win) that it's correctly caught with a clear message🤖 Generated with Claude Code