Skip to content

[codex] fix config precedence resolution#609

Merged
abtreece merged 2 commits into
mainfrom
codex/fix-config-precedence
May 8, 2026
Merged

[codex] fix config precedence resolution#609
abtreece merged 2 commits into
mainfrom
codex/fix-config-precedence

Conversation

@abtreece
Copy link
Copy Markdown
Owner

@abtreece abtreece commented May 8, 2026

Summary

  • Track whether config options came from CLI arguments or environment variables before merging TOML
  • Apply TOML only when the option was not explicitly supplied by CLI/env
  • Move backend node defaults after TOML resolution so config-file nodes can apply
  • Add precedence regression coverage for explicit default-valued CLI/env settings

Why

Fixes #601. The old merge logic compared parsed values against hard-coded defaults, so an explicit default-valued CLI/env setting could be treated as unset and overwritten by TOML.

Validation

  • go test ./cmd/confd
  • go test ./...

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.01%. Comparing base (78e3430) to head (ce45a61).

Files with missing lines Patch % Lines
cmd/confd/config.go 62.74% 10 Missing and 28 partials ⚠️
cmd/confd/cli.go 88.88% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #609      +/-   ##
==========================================
+ Coverage   70.83%   71.01%   +0.17%     
==========================================
  Files          53       53              
  Lines        5644     5682      +38     
==========================================
+ Hits         3998     4035      +37     
- Misses       1418     1419       +1     
  Partials      228      228              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abtreece abtreece marked this pull request as ready for review May 8, 2026 03:35
Copilot AI review requested due to automatic review settings May 8, 2026 03:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes configuration precedence between CLI flags, environment variables, and the TOML config file by tracking whether options were explicitly provided via CLI/env (even when set to their default values), and only applying TOML values when an option wasn’t explicitly supplied. It also delays backend node defaulting until after TOML resolution so config-file-provided nodes can take effect.

Changes:

  • Track explicit config sources (CLI vs env) using Kong parse context metadata and gate TOML application accordingly.
  • Apply backend node defaults after TOML merge to ensure config-file nodes aren’t overridden by command defaults.
  • Add regression tests covering explicit default-valued CLI/env options and backend precedence behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
cmd/confd/config.go Introduces explicit-source tracking + shouldApplyTOML() to correctly resolve precedence using TOML metadata and Kong parsing info.
cmd/confd/cli.go Captures explicit-source info via AfterApply() and centralizes backend node defaults in applyBackendDefaults() after TOML merge.
cmd/confd/config_test.go Adds precedence regression tests for explicit default-valued CLI/env settings and backend default-vs-TOML precedence.
cmd/confd/cli_test.go Updates precedence test setup for new explicit-source tracking and adds direct coverage for applyBackendDefaults().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@abtreece abtreece merged commit 9837764 into main May 8, 2026
15 checks passed
@abtreece abtreece deleted the codex/fix-config-precedence branch May 8, 2026 03:47
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.

refactor: replace manual config precedence merging

2 participants