Skip to content

fix(config): config unset with --dry-run deletes the key #3218

Closed

Description

@dan-petty

What happened

devops --dry-run config unset <key> removes the key and writes a backup. A dry run must write nothing.

Reproduced on main (24ef67ac) in a plain clone with a temporary HOME and a config of two keys:

$ devops --dry-run config unset ai.model
Removed ai.model from <config>.yaml:3.
The file before the change is in <config>.yaml.bak-<stamp>.

The key is gone from the file after the command, and the backup file exists. devops config unset ai.model --dry-run (the option after the command) exits 2 with "No such option: --dry-run", so the only form that is accepted is the global option, and that form deletes.

Cause

unset_value (src/devops_cli/commands/config.py:313-334) has no dry_run parameter and calls remove_config_key(key, dry_run=False). No code reads removal.diff. Commit 47cdf0d (#2963, closes #2255) removed the preview that #2207 had added, and tests/commands/test_config.py:158 now asserts that --dry-run config unset removes the line. The spec requirement "--dry-run writes nothing", with the diff printed, at openspec/specs/config-commands/spec.md:156 disagrees with the code.

What should happen

  • A dry run of config unset writes nothing: it does not change the config file and does not write a backup.
  • It prints the diff of the removal, with the value of a credential key redacted. write_history.credential_paths is the source of the credential key paths.
  • The test at tests/commands/test_config.py:158 asserts the new behavior.
  • The spec and the code agree.

Source

Found while fixing the plan pull request #3158 for #2740. #2740 (a dry-run preview that prints the value of a credential) is superseded: there is no preview to redact today, and this issue restores the preview with a redacted diff. The plan PR #3158 should close unmerged once #2740 is rejected or rewritten.

Related: #2740, #2963, #2255, #2207.

Proposed design

Problem statement

A dry run of devops config unset deletes the key and writes a backup. A dry run must write nothing. It must print the removal diff with credential values redacted. The test and the spec must agree with this behavior.

Acceptance criteria

Requirement: Dry run writes no config change

The command devops --dry-run config unset SHALL leave the config file unchanged and SHALL NOT create a backup file.

Scenario: Dry run keeps the key

  • WHEN The config file holds ai.model and the user runs devops --dry-run config unset ai.model.
  • THEN The config file content is unchanged and no .yaml.bak- file exists.

Requirement: Dry run prints the removal diff

The command devops --dry-run config unset SHALL print the diff of the removal.

Scenario: Dry run shows the removed line

  • WHEN The config file holds ai.model and the user runs devops --dry-run config unset ai.model.
  • THEN The output contains a diff that shows the removal of the ai.model line.

Requirement: Credential value redacted in dry-run diff

The dry-run diff SHALL replace the value of a credential key with ***REDACTED***.

Scenario: Credential value is hidden

  • WHEN The config file holds a credential key and the user runs devops --dry-run config unset .
  • THEN The output contains ***REDACTED*** and does not contain the credential value.

Requirement: Dry-run test asserts no write and redacted diff

The config unset test SHALL assert that a dry run writes nothing and prints a redacted diff.

Scenario: Test covers dry-run unset

  • WHEN The test suite runs tests/commands/test_config.py.
  • THEN The dry-run unset test passes and checks the unchanged file, the absent backup, and the redacted diff.

Requirement: Spec and code agree on dry-run behavior

The config-commands spec and the config unset command SHALL state that a dry run writes nothing and prints the removal diff.

Scenario: Spec text matches the command

  • WHEN A reader compares the config-commands spec with the dry-run behavior of config unset.
  • THEN Both state that the dry run writes no file and no backup, and prints the removal diff.

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers this need: the defect is in devops-cli's own config unset command. The change edits existing code, so the written cost is small: about 2,000 tokens to build, keep and fix, and under one hour of elapsed time.

Key questions

  • What must a dry run of config unset write?: A dry run must write no config change and no backup. It must print the removal diff. [sources: openspec/specs/config-commands/spec.md:156, src/devops_cli/commands/config.py:313-334]
  • Should config unset accept --dry-run after the command as a command option?: No. Keep the global --dry-run option only. (best practice) [sources: src/devops_cli/commands/config.py:315, tests/commands/test_config_workspace_docs_dry_run.py:71]
    • Chosen: Global --dry-run only. The command already uses the shared dry-run decorator, and the test classifies it as no-external-request.
    • Rejected: Add a command-level --dry-run option. This duplicates the global option and changes the command surface beyond the defect.
    • Rejected: Accept both forms. This adds a second path with no need and no test.
  • How should the command produce the dry-run diff?: Print the diff field from the remove_config_key result. (best practice) [sources: src/devops_cli/commands/config.py:313-334, openspec/specs/config-commands/spec.md:156]
    • Chosen: Print removal.diff. The removal result already holds the diff, and the command currently ignores it.
    • Rejected: Recompute the diff in the command. This duplicates removal logic and can disagree with the result.
    • Rejected: Print only the key and line number. The spec requires the diff, not only the location.
  • How should the dry-run diff redact a credential value?: Use the credential key paths from write_history.credential_paths and show ***REDACTED*** in place of the value. (best practice) [sources: src/devops_cli/commands/config.py:315, openspec/specs/config-commands/spec.md:156]
    • Chosen: Use write_history.credential_paths and ***REDACTED***. This reuses the project's credential path source and the existing redaction marker.
    • Rejected: Redact by key name pattern. This duplicates the credential path list and can miss a configured key.
    • Rejected: Print the diff with no redaction. This leaks a credential value in the preview.
  • What should the existing dry-run test at tests/commands/test_config.py:158 assert?: It must assert that the dry run leaves the file unchanged, writes no backup, and prints a redacted diff. (best practice) [sources: tests/commands/test_config.py:158, openspec/specs/config-commands/spec.md:156]
    • Chosen: Replace the removal assertion with the dry-run assertion. The current assertion records the defect and contradicts the spec.
    • Rejected: Add a new test and keep the old assertion. The old assertion would still fail the new behavior.
    • Rejected: Remove the test. The behavior needs a regression test.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/config
    status/new
    value/medium
    effort/medium
    on Nov 2, 2026
  2. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    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: P0-Critical. P0: the regression commit 47cdf0d is evidence GitHub confirms, from a trusted source.
    • Value: Medium. Users who rely on --dry-run to preview changes will lose their config key and get an unexpected backup file.
    • Effort: Medium. Requires adding a dry_run parameter, restoring the preview with credential redaction, updating the test, and aligning the spec.
    • Related: fix(config): devops config unset --dry-run prints the credential that it would remove #2740, which asks for a different change. Both concern config unset --dry-run and credential redaction, but the candidate also fixes the file deletion and restores the missing preview.
  3. added
    priority/p0-critical
    status/ready
    and removed
    status/new
    on Nov 2, 2026
  4. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

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

  5. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/3218-config-unset-with-dry-run-deletes, draft pull request #3234. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Make a dry run of config unset write nothing and print the redacted diff: 17713 tokens
    2. State the dry-run diff and the redaction in the config-commands spec: 8930 tokens

    The plan run made 2 model request(s), and used 96736 input tokens and 2985 output tokens. The tool calls, in order:

    1. read_file({"path":"src/devops_cli/commands/config.py","start_line":280,"end_line":360})
    2. read_file({"path":"tests/commands/test_config.py","start_line":1,"end_line":220})
    3. read_spec({"capability":"config-commands","requirement":"devops config unset --dry-run writes nothing"})
  6. added 2 commits that reference this issue on Nov 2, 2026
  7. added
    status/planned
    and removed
    status/ready
    on Nov 2, 2026
  8. dan-petty commented on Nov 4, 2026

    @dan-petty
    OwnerAuthor

    Amendment that the plan of this issue needs. It comes from the close of #2740, which this plan supersedes.

    The defect in the plan. Task 1.2 of openspec/changes/3218-config-unset-with-dry-run-deletes/tasks.md redacts only previous, and it builds the diff against content. _redact drops a comment line that holds the replaced value (src/devops_cli/config/write_history.py:85), and round_trip.edit keeps that line in content (src/devops_cli/config/settings.py:1714). So the diff shows the comment as an added line, with the credential value in it. A run with fake data on main, with the steps of task 1.2, reproduced this. Removing the key from the redacted text gave a diff with only the redacted line.

    The amendment.

    • Task 1.2: build the diff from the redacted text on both sides. content for the live write stays unredacted.
    • Task 1.1: add a dry-run test with a comment line that holds the credential value, and assert that no diff line holds the value.
    • The spec delta specs/config-commands/spec.md: add the matching scenario.

    How. An amendment by the job cannot change a spec delta (docs/ROADMAP_WORKFLOW.md:163), and the job reads tasks.md from the default branch (tasks_on_default in src/devops_cli/roadmap/planned.py). So open a docs(openspec) pull request that changes the folder before an implement run takes this item.

    Also from #2740. The value of a key that is not a credential stays in the diff as the file writes it. The live run stays as it is, and tests/config/test_config_key_removal.py:208 and :249 cover it. The reproduction steps of #2740 stay readable on that issue.

  9. added
    status/in-progress
    and removed
    status/planned
    on Nov 4, 2026
  10. added
    status/in-review
    and removed
    status/in-progress
    on Nov 4, 2026
  11. removed
    status/in-review
    on Nov 4, 2026
  12. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor
  13. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-04 21:19 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/mediumpriority/p0-criticalscope/configtype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions