Skip to content

fix(agent): load environment variables when no config file is provided#171

Merged
s0up4200 merged 2 commits into
developfrom
fix/agent-env-vars
Jan 24, 2026
Merged

fix(agent): load environment variables when no config file is provided#171
s0up4200 merged 2 commits into
developfrom
fix/agent-env-vars

Conversation

@s0up4200

@s0up4200 s0up4200 commented Jan 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The agent command was using config.New() when no --config flag was provided, which skips environment variable loading entirely. Env vars like NETRONOME__AGENT_HOST, NETRONOME__AGENT_PORT, and NETRONOME__AGENT_API_KEY were silently ignored.
  • Now uses config.Load() which searches for config files in default paths and always applies environment variable overrides, matching the behavior of the serve command.

Test plan

  • Start agent with NETRONOME__AGENT_HOST and NETRONOME__AGENT_PORT env vars set (no --config flag) and verify it binds to the correct address
  • Start agent with NETRONOME__AGENT_API_KEY set and verify authentication is enabled
  • Start agent with both env vars and CLI flags, verify CLI flags take precedence
  • Start agent with --config flag and verify config file + env vars still work as before

Closes #102

Summary by CodeRabbit

  • Bug Fixes
    • Improved configuration loading behavior with better default fallback handling.
    • Command-line flags now reliably override configuration file and environment settings for logging level, host, port, interface, API key, and disk inclusion/exclusion options.

✏️ Tip: You can customize this high-level summary in your review settings.

The agent command was using config.New() when no --config flag was
provided, which skips environment variable loading entirely. This meant
env vars like NETRONOME__AGENT_HOST, NETRONOME__AGENT_PORT, and
NETRONOME__AGENT_API_KEY were silently ignored.

Now uses config.Load() which searches for config files in default paths
and always applies environment variable overrides, matching the behavior
of the serve command.

Closes #102
@s0up4200

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 24, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jan 24, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Modified config loading in the agent's main function to unconditionally load configuration files, gracefully fall back to defaults on failure, and apply command-line flag overrides with proper precedence after loading. Logger initialization was moved post-config to ensure correct configuration propagation.

Changes

Cohort / File(s) Summary
Config Loading Refactor
cmd/netronome/main.go
Changed from conditional to unconditional config loading; added graceful fallback to defaults on load failure; implemented post-load CLI flag overrides for host, port, interface, api-key, diskIncludes, diskExcludes, and log-level to establish proper config precedence

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰✨ With files loaded true and flags applied with care,
Environment whispers finally heard in the air,
No more defaults when the config should reign,
Precedence flows just right, no more pain! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing conditional config loading with unconditional config.Load() to respect environment variables when no config file is provided.
Linked Issues check ✅ Passed The PR directly addresses issue #102 by ensuring environment variables (NETRONOME__AGENT_HOST, NETRONOME__AGENT_PORT, NETRONOME__AGENT_API_KEY) are loaded and applied when no config file is provided.
Out of Scope Changes check ✅ Passed All changes are scoped to resolving environment variable loading; no unrelated modifications to other functionality or code areas are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@s0up4200 s0up4200 merged commit 59d16f3 into develop Jan 24, 2026
11 checks passed
@s0up4200 s0up4200 deleted the fix/agent-env-vars branch January 24, 2026 10:01
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.

Agent : Environments variable aren't working

1 participant