fix(cli): warn on duplicate global flags instead of silently last-wins (#243)#301
Open
RUNECTZ33 wants to merge 1 commit into
Open
fix(cli): warn on duplicate global flags instead of silently last-wins (#243)#301RUNECTZ33 wants to merge 1 commit into
RUNECTZ33 wants to merge 1 commit into
Conversation
entrius#243) Steps to reproduce: `alw view rates --netuid 7 --netuid 8` previously took 8 silently with no indication anywhere that 7 was overridden. Fix: track seen canonical keys in parse_global_flags; on a duplicate, keep the existing last-wins behavior (preserves any operator scripts that relied on it) but surface the override via stderr so a typo becomes visible immediately rather than producing surprise downstream. warning: duplicate global flag --netuid '8' overrides earlier --netuid '7' Closes entrius#243
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
Closes #243.
alw view rates --netuid 7 --netuid 8previously took 8 silently — no indication anywhere that 7 was discarded.parse_global_flagssimply overwrote the dict entry on the second match.Change
Track seen canonical keys in
parse_global_flags. On a duplicate, keep the existing last-wins behavior (preserves any operator scripts that depended on it) but surface the override viastderr:Same handling for both
--flag valueand--flag=valueforms.Why warn rather than reject
Issue says "Warn or reject duplicate globals." I picked warn to:
If maintainers prefer hard rejection instead, happy to flip — change is one branch in the same function.
Scope
allways/cli/swap_commands/helpers.py: +28 / -2. No new imports (sysalready imported). Output goes viaprint(..., file=sys.stderr)so it doesn't pollute stdout for any tooling that pipes the CLI's normal output.Test plan
python3 -c "import ast; ast.parse(...)"argv=['alw', 'view', 'rates', '--netuid', '7', '--netuid', '8']→overrides={'netuid': '8'}+ stderr warningargv=['alw', 'view', 'rates', '--netuid=7', '--netuid=8']→ same outcomeargv=['alw', 'view', 'rates', '--netuid', '7']→overrides={'netuid': '7'}+ no warningsys.stderris the right channel — CLI's normal stdout output (rates table, etc.) stays intact for piping.