Skip to content

Render server flag rejections from the lists the guards test - #165

Merged
drumih merged 1 commit into
mainfrom
fix/server-flag-rejection-messages
Aug 29, 2026
Merged

Render server flag rejections from the lists the guards test#165
drumih merged 1 commit into
mainfrom
fix/server-flag-rejection-messages

Conversation

@drumih

@drumih drumih commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Fixes #164.

--prefill-chunk-tokens rejected an invalid value with must be 32, 64, or 128 while accepting 256. PR 144 widened allowedPrefillChunkTokens and derived the resolver-path message, but the parse-path literal stayed behind and no test read the message, so 0.5.0 through 0.7.1 all shipped it. --expert-cache-slots restated its list the same way at two sites.

What changes

  • ServerArguments.allowedValueList(_:) renders the choice list once; ServerArgumentError.notAllowed(flag:allowed:) builds every --expert-cache-slots and --prefill-chunk-tokens rejection from the array the guard tests. Both --help lines interpolate the same renderer, so help and errors cannot disagree.
  • Accepted values are unchanged. The only message text that changes is --prefill-chunk-tokens: the parse path gains 256, and the resolver path reads must be 32, 64, 128, or 256 instead of must be one of 32, 64, 128, 256. --expert-cache-slots text and the rendered --help are byte-identical to before.

Tests

Four new tests in ServerArgumentTests: the renderer, the parse-path rejection (parameterized over both flags with numeric and non-numeric bad values), the resolver-path rejection, and the help lines. Each compares the integer set in the text against the allowed array, so an omitted legal value and a named illegal one both fail.

  • swift test --filter ServerArgumentTests: 14/14.
  • With the original parse-path literal restored, exactly the two --prefill-chunk-tokens cases fail ([32, 64, 128] vs [32, 64, 128, 256]).
  • TurboFieldfareServer --model /nonexistent --prefill-chunk-tokens 512 now prints error: --prefill-chunk-tokens must be 32, 64, 128, or 256; --prefill-chunk-tokens 256 passes argument parsing as before.

An invalid --prefill-chunk-tokens was rejected with "must be 32, 64, or
128" while the guard beside it accepted 256: PR 144 widened the allowed
list and derived the resolver-path message, but left the parse-path
literal behind, and no test read the message. Every release since 0.5.0
shipped it. --expert-cache-slots restated its list the same way at two
sites, accurate only until that list moves.

One renderer now produces the choice list for the help text and every
rejection, and ServerArgumentError.notAllowed builds each message from the
array the guard tests. Tests pin the exact integer set named by the
parse-path and resolve-path rejections and by the help lines; with the old
literal restored, the two --prefill-chunk-tokens rows fail and nothing
else does.

Fixes #164
@drumih
drumih merged commit 614a8f6 into main Aug 29, 2026
2 checks passed
@drumih
drumih deleted the fix/server-flag-rejection-messages branch August 29, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: --prefill-chunk-tokens rejection message omits 256

1 participant