fix: cake serve fails with "required argument was not provided: address" - #89
Open
SAGAR-TAMANG wants to merge 1 commit into
Open
fix: cake serve fails with "required argument was not provided: address"#89SAGAR-TAMANG wants to merge 1 commit into
SAGAR-TAMANG wants to merge 1 commit into
Conversation
`cake serve <model>` is unusable in any release build:
$ cake serve evilsocket/Qwen3-0.6B
error: The following required argument was not provided: address
Usage: cake <COMMAND>
Clap derives an argument's ID from the field name, not from the `long`
attribute. The `Serve` variant declares a field named `address` (exposed as
`--api`) and also flattens `Args`, which has its own `address` field (exposed
as `--address`). Both register under the ID "address" in the same command.
Clap validates ID uniqueness with debug assertions, which are compiled out by
`--release`. Instead of panicking, the resulting command has a malformed
argument table: both default values are dropped, "address" is treated as
required, and the usage line degenerates to `cake <COMMAND>`.
`Run` is unaffected -- it flattens `Args` without declaring an `address` field
of its own, so `cake run <model> --api <addr>` works and is an exact
workaround, since `Serve` only sets `args.api` before delegating to the same
code path.
Fixed by renaming the field to `api_address`, which removes the collision and
makes the field name match the flag it produces, so the clash is harder to
reintroduce. No flags change: `--api` and `--address` behave as documented.
Co-Authored-By: Claude Opus 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.
Problem
cake serve <model>does not work in any release build:No combination of flags gets past it —
addresshas a default value in the source, so there is nothing the user can pass to satisfy it.This affects every release build regardless of feature selection.
cake serveis documented in the README and indocs/api.mdas the way to start the API server.Cause
Clap derives an argument's ID from the field name, not from the
longattribute. TheServevariant declares a field namedaddressand also flattensArgs, which has its ownaddressfield:Both register under the ID
"address"in the same command.Clap validates ID uniqueness with debug assertions, which
--releasecompiles out. Rather than panicking with a clear message, the built command ends up with a malformed argument table: both default values are dropped,addressis treated as required, and the usage line degenerates tocake <COMMAND>instead of a real one.Runis unaffected — it flattensArgswithout declaring anaddressfield of its own.Workaround for anyone hitting this
Serveonly setsargs.apibefore delegating to the same code path asRun:So this is an exact equivalent and does work today:
Fix
Rename the field to
api_address, removing the collision:Renaming was chosen over adding
#[arg(id = "...")]because it makes the field name match the flag it produces, so the collision is harder to reintroduce later.No user-facing flags change:
--apiand--addresscontinue to behave as documented.Context
Found while running cake on Android/Termux. The workaround above was verified working on that device;
cake run <model> --api 0.0.0.0:8080serves the OpenAI-compatible API correctly.Worth noting that no test currently exercises the CLI's argument parsing, which is why a broken headline subcommand could ship. A
Cli::command().debug_assert()test would have caught this at build time — clap provides it for exactly this purpose:Happy to add that in a follow-up if it would be welcome.
🤖 Generated with Claude Code