Skip to content

Plan #19: env vars override the YAML config file, as documented - #62

Merged
craigmcchesney merged 2 commits into
mainfrom
plan/19-env-overrides-yaml
Sep 24, 2026
Merged

craigmcchesney merged 2 commits into
mainfrom
plan/19-env-overrides-yaml

Conversation

@craigmcchesney

Copy link
Copy Markdown
Collaborator

Refs #19. This PR contains only the plan; the fix comes in a follow-up PR. I used Refs rather than Closes so the issue stays open until then.

Adds plan/tickets/19/plan.md, the triage and implementation plan for #19, for review before any code changes.

Summary

  • Verdict: implement. The ticket's diagnosis holds: MldpConfig.from_yaml() passes YAML values as init kwargs, which pydantic-settings ranks above MLDP_* env vars. 1.16.0 shipped with the bug; the config code is unchanged since 1.15.0.
  • Fix (D1): the YAML values get their own settings source, ranked below env and above defaults. from_yaml() passes its flattened values to that source through a ContextVar. I prototyped this against pydantic-settings 2.14.2 and every case matches the documented order.
  • Found in triage, not in the ticket (T4–T8):
    • Existing deployments whose env and YAML disagree will silently connect somewhere else after the fix. This needs a NEXT.md entry.
    • The tracked root mldp-config.yaml sets every key, which affects test isolation.
    • The test and cookbook changes needed go beyond what the ticket lists.
  • Resolved:
    • Q1: load_config(config_object=) returns the object as-is.
    • Q2: no logging of env overrides.
    • Q3 (is the next release breaking?) is left to the release cut.

Review focus

  • D1's ContextVar approach, and the alternatives it rejects.
  • D2: an invalid YAML value that an env var overrides no longer raises.
  • Whether the test matrix in task 3 is complete.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PsRVNfPSn4SG7UiU7m7hQq

Triage of the AI-drafted ticket and the implementation plan. The diagnosis
holds and still applies in 1.16.0. The plan adds what the draft skipped:
how a settings source learns the YAML path (a ContextVar-backed source
set by from_yaml(), prototyped), the silent retargeting of deployments
whose env and YAML disagree (a NEXT.md entry), the tracked root
mldp-config.yaml's effect on test isolation, and the wider doc and test
surface. Q1 (config_object returned as-is) and Q2 (no override logging)
are resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PsRVNfPSn4SG7UiU7m7hQq
Copilot AI lite review requested due to automatic review settings September 24, 2026 22:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Two moderate validation issues and one release-notes quality-gate issue remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR adds the implementation plan for fixing YAML/environment-variable precedence in configuration loading.

Changes:

  • Documents the ContextVar-backed YAML settings source design.
  • Defines implementation, testing, documentation, and release-note tasks.
  • Clarifies configuration-object behavior and rollout considerations.

Review findings require updates: add an identity assertion, test direct init-versus-environment precedence, and include the release-notes checker in quality gates.

File Summary
plan/​tickets/​19/​plan.md Triage, design, implementation tasks, and validation plan for issue #19.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread plan/tickets/19/plan.md Outdated
…ternative

- Task 3: build the explicit config inside the patched environment, and
  assert identity, so the level-1 test cannot pass against the old rebuild
  (Copilot review).
- Task 8: add the cookbook and release-notes checkers to the quality gates.
- D1: record the model_fields_set filter as a rejected alternative, and why.
- Task 2: switch the config_object guard to `is not None`.
- T7 line reference; T6 notes that existing tests stay unisolated (out of scope).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PsRVNfPSn4SG7UiU7m7hQq
@craigmcchesney
craigmcchesney merged commit 54558eb into main Sep 24, 2026
6 checks passed
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.

2 participants