Let CLI flags bootstrap config without a file or env#23
Conversation
load_config errored on a missing AGENT_NOTIFY_TOKEN before main() applied the --token/--server flags, so the flags alone could not start the bridge when no bridge.toml or env var was present. Defer the requirement: load_config now returns an empty token instead of erroring, the token field is serde(default) so a file may omit it, and the merged config (file/env + CLI overrides) is checked by a new settings::validate() called from main(). Any single layer supplying the token is now accepted. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23 +/- ##
==========================================
+ Coverage 52.10% 58.25% +6.14%
==========================================
Files 8 8
Lines 1023 1121 +98
==========================================
+ Hits 533 653 +120
+ Misses 490 468 -22
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
6facd75 to
746c91f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6facd75dfb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
load_config returned early on a config file, so AGENT_NOTIFY_TOKEN was only ever read in the no-file path. A bridge.toml that set server_url but omitted the token (the common setup where the secret lives in the environment) then failed validation unless --token was passed. Build the config in layers instead: an environment-derived base is overlaid by the file's set fields (file > env > default, per field), so an omitted token falls back to AGENT_NOTIFY_TOKEN. Extracted overlay_file as a pure function and added tests for the merge, including the file-server + env-token case. Addresses Codex review feedback on #23. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@cursor review |
PR SummaryLow Risk Overview
Unit tests cover Reviewed by Cursor Bugbot for commit 5078aa8. Configure here. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 5078aa8. Configure here.
Problem
load_configerrored on a missingAGENT_NOTIFY_TOKENbeforemain()applied the--token/--serverCLI flags. So when there was nobridge.tomland no env var, passing the flags alone could not start the bridge:The flags were applied only after the load already failed.
Fix
Defer the requirement check until the config layers are merged:
load_configreturns an empty token instead of erroring whenAGENT_NOTIFY_TOKENis unset, so CLI flags can still supply it.BridgeConfig::tokenis now#[serde(default)], so abridge.tomlmay setserver_urland leave the token to--token/the env var.settings::validate()checks the fully-merged config (file/env + CLI overrides) and is called frommain()after the overrides are applied. A token from any layer now satisfies the requirement, and the error message lists all three sources.Precedence is unchanged: CLI flags override the file/env base.
Tests
New unit tests in
settings.rs:validateaccepts a complete config and rejects a blank token / blank server (with the expected messages).cli_token_bootstraps_base_without_token— mirrorsmain(): an empty-token base (as from the env path with noAGENT_NOTIFY_TOKEN) fails, then validates once a--tokenoverride is applied.read_configparses a file that omits the token (defaulted) and a fully-populated file.cargo fmt --check, workspaceclippy -D warnings, andcargo testall pass.End-to-end: with no
bridge.tomland no env vars,agent-notify-bridge --server ... --token ... --mock-displaynow boots into the tray + worker connect loop instead of erroring on a missing token.🤖 Generated with Claude Code