fix(scale): derive the legacy arg normalizer's option list from clap - #1042
Open
codyde wants to merge 1 commit into
Open
fix(scale): derive the legacy arg normalizer's option list from clap#1042codyde wants to merge 1 commit into
codyde wants to merge 1 commit into
Conversation
`railway scale --project <id>` failed with "Invalid replica count", while `-p <id>` worked. `normalize_legacy_scale_args` rewrites unrecognized `--foo bar` into the positional `foo=bar` to keep the legacy `--<region> <count>` spelling working. It kept its own hand-maintained list of scale's options, which had drifted from `Args`: `--project` (added in #893, after the normalizer landed in #881) was missing, so it became the positional `project=<id>` and was parsed as `REGION=REPLICAS`. Derive the long and short option sets from `Args::command()` instead of restating them, so a new option on `Args` cannot reintroduce this. `railway service scale` reuses the same `Args` type, so both entry forms share one source of truth.
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
railway scale --project <id>fails withInvalid replica count;-p <id>works.normalize_legacy_scale_argsrewrites unrecognized--foo barinto the positionalfoo=bar, to keep the legacy--<region> <count>spelling working. It kept a hand-maintained copy of scale's options that had drifted fromArgs:--project(added in #893, after the normalizer landed in #881) was missing, so it becameproject=<id>and was parsed asREGION=REPLICAS.Closes #1024.
Resolution
Args::command()instead of restating them, so a new option onArgscannot reintroduce this.railway service scalereuses the sameArgstype — both entry forms now share one source of truth.--versionstays explicit: it is propagated from the root command, not declared onArgs.Verification
Against a live project,
before= 5.30.4:scale --project <id> …Invalid replica countscale --project=<id> …Invalid replica countscale -p <id> …service scale --project <id> …Invalid replica countscale --us-west2 1(legacy)