Skip to content

fix(config): a refused value in the config file ends with a traceback #4610

Closed

Description

@dan-petty

Problem Description

When a settings validator refuses a value in the config file, the command stops with a Python traceback. The text of the error is correct, but a traceback follows it. load_settings in src/devops_cli/config/settings.py re-raises the pydantic ValidationError when no key is unknown, and the wrapper of new_typer() reports only a DevOpsCLIError. The same value in an environment variable gives one clean line, because _variable_error turns it into a ConfigurationError.

Reproduction Steps

  1. Write a config file with roadmap:\n implement:\n effort: ["huge"]\n, or with service:\n repos: ["Owner/Repo", "owner/repo"]\n.
  2. Run DEVOPS_CLI_CONFIG=<file> uv run devops roadmap inbox.

Expected vs Actual Behavior

Expected: one error line that names the setting and the reason, and exit status 1, as for an environment variable (Environment variable DEVOPS_CLI_SERVICE_REPOS cannot set service.repos: ...).

Actual: Command 'roadmap' failed: 1 validation error for Settings, the pydantic text with its URL https://errors.pydantic.dev/..., then Traceback (most recent call last): and the stack. Exit status 1.

Environment Diagnostics

devops-cli at commit 5f75d25 of main, Python 3.14, pydantic 2.13. The error does not depend on the host.

Logs, Traces, or Terminal Output

Command 'roadmap' failed: 1 validation error for Settings
roadmap.implement.effort.0
  Value error, The setting roadmap.implement.effort holds 'huge'. That is no effort value. Use low, medium or high. [type=value_error]
    For further information visit https://errors.pydantic.dev/2.13/v/value_error
Traceback (most recent call last):

Existing Tool Considered

pydantic gives each error its location (loc) and message. _format_validation_error in settings.py already formats them for dotted_set. A ConfigurationError from those parts needs no new tool.

Source: #4533

Alternatives check of 2026-11-13: not-applicable.
Class: fix-with-stack-trace, no search.
Tool: none found.

Proposed design

Problem statement

A settings validator that refuses a value in a config file raises a pydantic ValidationError through load_settings. The Typer wrapper reports only a DevOpsCLIError, so the command prints the pydantic text and a traceback. A refused environment variable already becomes a ConfigurationError with one clean line. The change converts a refused config-file value into a ConfigurationError that names the setting, the file and the reason.

Acceptance criteria

Requirement: Config file value error is one clean line

load_settings SHALL raise a ConfigurationError that names the setting, the file and the reason when a config file value is refused.

Scenario: Refused effort value in a config file

  • WHEN a config file sets roadmap.implement.effort to ["huge"] and load_settings reads it
  • THEN the call raises ConfigurationError, its message names roadmap.implement.effort and the reason, and it holds no pydantic URL and no traceback

Requirement: CLI exits 1 with no traceback for a refused config value

The command that loads a config file with a refused value MUST exit with status 1 and print one error line with no traceback.

Scenario: Roadmap inbox with a refused config value

  • WHEN DEVOPS_CLI_CONFIG names a file that sets roadmap.implement.effort to ["huge"] and devops roadmap inbox runs
  • THEN the command exits with status 1 and prints one error line that names roadmap.implement.effort and the reason, with no Traceback (most recent call last):

Requirement: Duplicate service repo in a config file

When a config file holds two spellings of one service.repos entry, load_settings SHALL raise a ConfigurationError that names service.repos and the repeated repository.

Scenario: Duplicate repository in a config file

  • WHEN a config file sets service.repos to ["Owner/Repo", "owner/repo"] and load_settings reads it
  • THEN the error names service.repos and the repeated repository, and no traceback follows it

Requirement: Environment variable error stays clean

The change MUST keep the existing ConfigurationError message for a refused value that an environment variable gives.

Scenario: Refused service repo in an environment variable

  • WHEN DEVOPS_CLI_SERVICE_REPOS holds a value that the service.repos validator refuses and no config file sets that key
  • THEN the error message starts with Environment variable DEVOPS_CLI_SERVICE_REPOS cannot set service.repos: and no traceback follows it

Requirement: Unknown config key error stays clean

The change MUST keep the existing unknown-key error that names the file, the line and the command that removes the key.

Scenario: Unknown key in a config file

  • WHEN a config file holds an unknown key and load_settings reads it
  • THEN the error names the file, the line and the command that removes the key, and no traceback follows it

Existing Tool Considered

The alternatives check is not-applicable and names no tool. pydantic, already a dependency, covers the validation and gives each error's loc and msg; it lacks a CLI-facing ConfigurationError, so the change adds a small adapter in load_settings. Written cost: about 5,000 tokens to write and test the adapter, about 1,500 tokens to keep and fix it, and about 1 hour of elapsed time. No new library is added.

Key questions

  • Does a ConfigurationError produce one error line and exit status 1 with no traceback?: Yes. ConfigurationError subclasses DevOpsCLIError, and the wrapper of new_typer reports a DevOpsCLIError in one line and exits with its exit_code, with no traceback. [sources: src/devops_cli/exceptions/config.py:10, ARCHITECTURE.md:173, src/devops_cli/core/cli.py]
  • Where should the config-file ValidationError become a ConfigurationError?: In load_settings, after the unknown-key handling. That function has the ConfigLayers and the active path, and it keeps _settings_from free of file knowledge. (best practice) [sources: src/devops_cli/config/settings.py, src/devops_cli/config/unknown_keys.py]
    • Chosen: In load_settings after unknown-key handling. It has the ConfigLayers and the active path, and it mirrors the existing unknown-key error.
    • Rejected: In _settings_from. It has no file paths, and _variable_error already owns variable errors there.
    • Rejected: In the Typer wrapper. It cannot name the setting or the file, and it would catch pydantic errors from code that is not config loading.
  • What message should the ConfigurationError give for a refused config-file value?: Mirror the variable message: Config file <path> cannot set <key>: <location>: <reason>. Use the reason from pydantic without the Value error prefix and without the pydantic URL. (best practice) [sources: src/devops_cli/config/settings.py:2340, src/devops_cli/config/settings.py:280]
    • Chosen: Mirror the variable message with the file path. It is consistent with _variable_error, names the setting and the reason, and gives the file to edit.
    • Rejected: Use _format_validation_error alone. It names the setting and reason but not which of the two files holds the value.
    • Rejected: Keep the pydantic text and strip only the traceback. The pydantic URL and multi-line text remain, and the expected one line is not met.
  • Which key should the error name?: The longest prefix of the pydantic loc that is a declared config key, such as roadmap.implement.effort for roadmap.implement.effort.0 and service.repos for service.repos.0. (best practice) [sources: src/devops_cli/config/settings.py:2340, src/devops_cli/config/settings.py:280, src/devops_cli/config/settings.py]
    • Chosen: Longest declared config-key prefix of loc. It names a settable key such as roadmap.implement.effort, not the list index.
    • Rejected: Full loc joined. It includes the list index and may name no settable key.
    • Rejected: First part of loc. It names only roadmap or service, which is too broad to fix.
  • Which config file path should the error name?: The config file that holds the key: the project config file when it holds the key, else the global config file. (best practice) [sources: src/devops_cli/config/settings.py, src/devops_cli/config/unknown_keys.py]
    • Chosen: The config file that holds the key. It names the file to edit, even when both layers exist.
    • Rejected: Always the active config path. When the global file holds the key and a project file exists, it names the wrong file.
    • Rejected: Name no file. A person must search both files.
  • Should the change convert a validation error whose location no config file key matches?: No. Convert only an error whose longest config-key prefix is in a config layer. Re-raise any other ValidationError as it is, so a cross-field error from variables is not misnamed as a file error. (best practice) [sources: src/devops_cli/config/settings.py:2340, src/devops_cli/config/settings.py]
    • Chosen: Only errors whose location matches a key in a config layer. It is targeted and does not misname a cross-field error from variables.
    • Rejected: All remaining ValidationError objects. A model-level error may have no file key and could be caused by variables.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/bug
    scope/config
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 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 fix prefix of the title gives the type.
    • Scope: scope/config. The (config) scope of the title gives the scope.
    • Priority: P2-Medium. The error text is correct but wrapped in a traceback; it is a UX defect, not a data-loss or security issue.
    • Value: Medium. Users see a noisy traceback instead of one clean line; the information is present but harder to read.
    • Effort: Low. The body states that _format_validation_error already exists and a ConfigurationError needs no new tool, so the fix is a small re-raise change in load_settings.
    • Related: fix(review): catch findings.json validation errors #2644, which asks for a different change. Both items fix a pydantic validation error that leaks a traceback to the user, but in different code paths: settings.py for config values versus findings.json readers in the review command.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: fix-with-stack-trace. The check makes no search and no model call for an item of this class.

    Tool: none found

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

  6. added
    status/ready
    and removed
    status/new
    on Nov 14, 2026
  7. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 0410772 (see proposed design in issue body).

  8. added
    status/in-review
    and removed
    status/ready
    on Nov 14, 2026
  9. removed
    status/in-review
    on Nov 14, 2026
  10. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-14 15:02 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/configsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions