fix(fetcher): fall back to env token when overlay token absent #71
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/VS-51-fetcher-env-token-fallback"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
A persisted
settings.agentbinaryfetcheroverlay saved through the admin UI without re-typing the redacted token persists with no token. Because the env seed only fills the section when no overlay exists (seed-once) and the seeded token is never written to the DB, that good env token is then shadowed forever: every fetch of the private Forgejo package returns 401, the agent catalog stays empty, and device-enrollment downloads 404 at/vervainagents/:id(surfaced in the apps/agent/<id>proxy as "agent download failed: 404 Not Found"). Hit in production on c-01; recovery required manually re-entering the token in the admin UI.Fix
Resolve the Forgejo token from
VERVAIN_AGENT_FETCHER_TOKEN/..._TOKEN_FILEwhen the overlay/config token is absent or blank. NewAgentBinaryFetcherConfig::apply_env_token_fallback()(with a testable corefill_forgejo_token_from) incrates/vervain-agent-fetch/src/config.rs, called at the two source-build sites: boot-time fetch (crates/vervain/src/boot.rs) and runtime UI apply (crates/vervain-web/src/settings_overlay.rs).incoming) is stored unchanged; only the in-memorycfgused to build the live source gets the env token.Verification
cargo fmt --check,cargo clippy --all-targets -D warnings,cargo build --all-targets,cargo test --liball pass (pre-commit hook). New unit tests cover absent / blank / explicit-wins / no-env-noop / http-source cases. An adversarial review confirmedbuild_sourcehas exactly two production callers, both guarded, and the seed path builds JSON only (no source), so no fallback site is missed.Closes #VS-51.