Skip to content

Accept a static token entry that names only token_env - #26

Open
0bserver07 wants to merge 3 commits into
tobi:mainfrom
0bserver07:fix/token-env-without-token
Open

Accept a static token entry that names only token_env#26
0bserver07 wants to merge 3 commits into
tobi:mainfrom
0bserver07:fix/token-env-without-token

Conversation

@0bserver07

@0bserver07 0bserver07 commented Aug 27, 2026

Copy link
Copy Markdown

Fixes #22 (thanks @jeonck, same diagnosis).

The README quick-start config doesn't load. StaticToken.token in crates/walgit-config/src/lib.rs has no #[serde(default)] while token_env does, so an entry that only names an environment variable dies in serde with missing field token before validate() gets a look. Every shipped example of token_env (README.md, walgit.example.toml, walgit.standalone.toml) hits it.

Three commits:

  1. Add the default and extend auth_modes_validate_fail_closed with the README entry, plus an entry that names neither key so the fail-closed path stays covered (validate already refuses it).
  2. walgit.example.toml told you to run walgit config check walgit.toml, which exits 2 because the path is the global --config flag; it now says walgit --config walgit.toml config check.
  3. The README auth table said mode none gives write; it gives admin too.

Checked with the README block written to a file: config check prints missing field token on main and config OK with this. cargo test -p walgit-config passes.

0bserver07 and others added 3 commits August 27, 2026 00:24
StaticToken.token at crates/walgit-config/src/lib.rs:212 carried no serde
default while token_env on the next line did, so an entry that named only an
environment variable failed to deserialize with "missing field token". Every
shipped example writes that shape, including README.md:19,
walgit.example.toml:48 and walgit.standalone.toml:36, so the quick start
config was rejected by "walgit --config walgit.toml config check". The field
now defaults to the empty string, and Config::validate at lib.rs:1491 still
refuses an entry that names neither token nor token_env, so a config with no
way in stays fail-closed as GOAL.md asks. tests::auth_modes_validate_fail_closed
parses the README entry and asserts the entry with neither form still errors;
it fails on the old struct with the same TOML parse error the binary printed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The header comment at walgit.example.toml:6 said "walgit config check
walgit.toml", but the check subcommand takes no positional argument and
running it that way prints "error: unexpected argument 'walgit.toml' found"
and exits 2. The path comes from the global --config flag declared at
crates/walgit-cli/src/lib.rs:42-48, so the comment now reads "walgit --config
walgit.toml config check". I ran that form against walgit.example.toml and
walgit.standalone.toml with the built binary and both print "config OK".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The auth mode table at README.md:143 described mode none as everyone being
anon with write, which understates what the mode does. AuthMode::None returns
a principal with write true and admin true at
crates/walgit-server/src/auth.rs:672-677, and AGENTS.md:78 states the same in
the security contract, so a reader of the README alone would not know that a
loopback run also hands out settings and policy.json writes. The row now says
write and admin. This is a documentation correction with no code change, so
the code cited above is the proof.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

server.auth.tokens[]: token_env-only entries fail to parse (missing field token), including the README quick-start

1 participant