Skip to content

refactor(config): one source chain declares the resolution order of every setting, through pydantic-settings sources #2445

Description

@dan-petty

Problem or Motivation

Part 2 of #1000. The resolution order of a setting is in two places. load_settings (config/settings.py) merges the global and project files and then _apply_env_overrides sets each variable with dotted_set. Settings is a BaseSettings, but load_settings builds it with model_validate, so pydantic-settings reads no source. Credentials resolve in another chain (security/secrets.py: keyring, Vault, environment, configuration). telemetry_from_environment applies a third, partial order.

Proposed Solution & Architectural Design

  • Settings.settings_customise_sources declares the one order: the variables (names from part 1's field metadata), the project file, the global file and the defaults. The file layers keep their cache and the unknown-key error (feat(config): devops config unset removes a key, and an unknown key's error names the line and that command #2201).
  • Credentials keep the keyring, Vault, environment and configuration chain, and the design records where it is declared.
  • _apply_env_overrides and the hand-written layering go. telemetry_from_environment uses the same sources.
  • A table test covers one secret and one plain setting across keyring, Vault, environment, file and default.

Target Subsystem

src/devops_cli/config/settings.py, src/devops_cli/security/secrets.py.

Existing Tool Considered

pydantic-settings settings_customise_sources, YamlConfigSettingsSource and custom sources. The design states which part pydantic-settings cannot hold, with the evidence.

Acceptance criteria

Related

Parent: #1000. Needs part 1 (field metadata). Related: #992, #2201.

Source: #1000

Activity

  1. added
    type/refactor
    source/agent
    status/new
    value/medium
    effort/medium
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/refactor. The item reorganises existing resolution logic into one pydantic-settings source chain without changing external behaviour.
    • Priority: P2-Medium. It is a maintainability refactor that depends on Part 1 and does not fix a user-facing defect.
    • Value: Medium. It removes three hand-written resolution chains and lowers the risk of inconsistent setting resolution.
    • Effort: Medium. It touches settings.py and secrets.py, adds custom sources, and requires a table test across five layers.
    • Related: refactor(config): each setting declares its variable and description on its settings field, and the option, variable and secret registries are derived from it #2444, which asks for a different change. Both are parts of #1000; #2444 adds field metadata, this item declares the resolution order from that metadata.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. added a commit that references this issue on Oct 28, 2026
  5. removed
    status/new
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumsource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions