Skip to content

fix(service): Use load_settings() in GET /config #2517

Closed

Description

@dan-petty

Problem Description

The Service route GET /config (get_configuration in src/devops_cli/server/routes/workspace.py) says that it returns the active, non-secret configuration. It builds Settings(), not load_settings(). Settings() holds its arguments and the field defaults, and reads no variable and no config file (Settings.settings_customise_sources, #2445). So the route returns the defaults, not the settings that the Service runs with.

Reproduction Steps

  1. Set a value in the config file, for example ai.model: example-model, or set DEVOPS_CLI_AI_MODEL=example-model.
  2. Start the Service and send GET /config.
  3. Read config.ai.model in the reply.

Expected vs Actual Behavior

  • Expected: config.ai.model is example-model, the value that load_settings() gives, with credentials redacted.
  • Actual: config.ai.model is the default of the field.

Environment Diagnostics

origin/main at 0137f23. Found while building #2445 (one resolution order for the settings).

Logs, Traces, or Terminal Output

None. The route builds settings = Settings() and dumps it.

Proposed design

Problem statement

The GET /config route in the Service constructs Settings() directly, which returns only field defaults. It should call load_settings(), which reads environment variables and the config file. As written, the route returns defaults instead of the active configuration the Service runs with.

Acceptance criteria

Requirement: Route uses load_settings

The get_configuration route SHALL call load_settings() to obtain the active configuration.

Scenario: Route calls load_settings

  • WHEN A client sends GET /config
  • THEN The route handler calls load_settings() and does not call Settings() with no arguments

Requirement: Env var override is reflected

The GET /config response SHALL reflect values set through environment variables.

Scenario: Env var overrides a default

  • WHEN DEVOPS_CLI_AI_MODEL is set to example-model and the Service is running
  • THEN config.ai.model in the response equals example-model

Requirement: Config file value is reflected

The GET /config response SHALL reflect values set in the config file.

Scenario: Config file sets a value

  • WHEN The config file contains ai.model: example-model and no env var overrides it
  • THEN config.ai.model in the response equals example-model

Requirement: Secrets remain redacted

The GET /config response SHALL redact all secret fields identified by secret_keys().

Scenario: Secret field is present

  • WHEN A secret field has a non-empty value in the loaded settings
  • THEN That field in the response equals REDACTED

Existing Tool Considered

The project already uses pydantic-settings (Pydantic BaseSettings) for configuration. The function load_settings() in devops_cli.config.settings already implements the correct loading path (env vars plus config file). The fix is a one-line change to call the existing function instead of the bare constructor. No new code is built.

Key questions

  • Where is load_settings() defined and what does it return?: load_settings() is in devops_cli.config.settings (the same module that defines Settings). It returns a Settings instance populated from environment variables and the config file. The body confirms it reads variables and the config file, unlike the bare Settings() constructor. [sources: src/devops_cli/server/routes/workspace.py:11]
  • Should the route call load_settings() or keep calling Settings()?: Call load_settings(). The route docstring says it returns the active non-secret configuration. Settings() returns only field defaults and reads no variable and no config file. load_settings() reads both, so it returns the settings the Service actually runs with. (best practice) [sources: src/devops_cli/server/routes/workspace.py:114]
    • Chosen: Call load_settings(). Returns the active configuration from env vars and config file, matching the route's stated purpose.
    • Rejected: Keep calling Settings(). Returns only field defaults. Does not read env vars or config file. Does not match the route's stated purpose.
  • Does the import line need to change?: Yes. The current import is from devops_cli.config.settings import Settings. The fix adds load_settings to that import: from devops_cli.config.settings import Settings, load_settings. The Settings import can be removed if no other code in the file uses it. (best practice) [sources: src/devops_cli/server/routes/workspace.py:11]
    • Chosen: Add load_settings to the existing import. Minimal change. Keeps the import from the same module.
    • Rejected: Add a separate import line. Unnecessary. Both names come from the same module.

Open questions

  • Are there other routes or code paths that construct Settings() directly instead of calling load_settings()? (missing verified source)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-04: none.
Tool: none found.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/medium
    effort/low
    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/bug. The route returns wrong data because it constructs Settings() instead of calling load_settings().
    • Priority: P2-Medium. A service endpoint returns incorrect configuration values, which misleads users, but it does not break core functionality or expose secrets.
    • Value: Medium. Users querying GET /config see defaults instead of their actual settings, which undermines trust in the diagnostic endpoint.
    • Effort: Low. The fix replaces one constructor call with load_settings() in a single route handler.
    • Related: refactor(config): a default that backs a settings field is read only through the settings, and an import-boundary test holds it #2447, which asks for a different change. Both ensure settings values are read through the proper loading path rather than raw defaults, but #2447 targets import boundaries for DEFAULT_* constants while the candidate fixes one route handler.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 0f7bc26 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Are there other routes or code paths that construct Settings() directly instead of calling load_settings()? (missing verified source)
  5. added
    scope/service
    on Oct 30, 2026
  6. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Tool: none found

    Lacks:

    • No external tool fixes the bug: the change is one call inside src/devops_cli/server/routes/workspace.py, replacing Settings() with the project's own load_settings().
    • The redaction the route needs is project-specific: the secret fields named by the project's secret_keys() must become REDACTED, which no settings-loading library provides.
    • pydantic-settings is already the settings library the project uses, and load_settings() wraps its loading path, so adopting it does not cover the remaining route change.
    • Generic settings docs (Pydantic, FastAPI) only show how to build and read a settings object; they do not provide a GET /config route or redaction of the project's secret fields.

    Searches run:

    • pydantic-settings load settings from environment variables and config file
    • library expose FastAPI settings endpoint redact secrets
    • python library redact secret fields when dumping settings model

    Sources:

    Checked on 2026-11-04. A person decides what this means for the item. The check changes no label and closes no issue.

  7. changed the title [-]fix(service): GET /config returns the field defaults, not the loaded settings[/-] [+]fix(service): Use load_settings() in GET /config[/+] on Nov 6, 2026
  8. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 63 characters, and the limit is 60. The type and the scope stay.

    • Before: fix(service): GET /config returns the field defaults, not the loaded settings
    • After: fix(service): Use load_settings() in GET /config
    • Source of the summary: the background model
  9. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 9, 2026
  10. removed
    status/in-review
    on Nov 9, 2026
  11. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-09 15:38 UTC

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/lowpriority/p2-mediumscope/servicesource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions