Skip to content

fix(config): devops config unset --dry-run prints the credential that it would remove #2740

Closed as not planned

Description

@dan-petty

Problem Description

devops config unset <key> --dry-run prints the unified diff of the removal. When the key is a plaintext credential, the diff holds the line of the credential, with its value. The command prints it in the console, so the value reaches the terminal, the scroll-back, a CI log or any tool that captures the output. The command exists to remove a credential from the file, and its preview prints that credential.

The live run prints no value: it prints the key, the file and the line only. The preview must print no value either. ConfigKeyRemoval.diff in src/devops_cli/models/config.py is built in remove_config_key in src/devops_cli/config/settings.py, with difflib.unified_diff over the whole text, and unset_value in src/devops_cli/commands/config.py passes its lines to render_dry_run_result.

Reproduction Steps

  1. Make a temporary HOME. Write the section ai to $HOME/.config/devops-cli/config.yaml, with the keys api_key (a fake value of your own) and model.
  2. Set PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring. Unset DEVOPS_CLI_CONFIG. Run devops config unset ai.api_key --dry-run in a directory with no project config file.

Expected vs Actual Behavior

Expected: the preview shows the key and its line, and shows no value of a credential. The value shows as a placeholder such as ***REDACTED***, as the copies of the file do after the change of #2645.

Actual: the diff list of the preview holds the removed line of ai.api_key with the fake value in clear text.

Environment Diagnostics

devops-cli 0.21.3 at origin/main ae446f0, Linux. Found while the change for #2645 (the copies of devops config unset hold no credential value) was built. That change redacts the copies, and it does not touch the preview.

Logs, Traces, or Terminal Output

"diff": [
  "--- <tmp>/home/.config/devops-cli/config.yaml",
  "+++ <tmp>/home/.config/devops-cli/config.yaml",
  "@@ -2 +1,0 @@",
  "-  <the line of ai.api_key, with the fake value in clear text>"
]

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Proposed design

Problem statement

devops config unset --dry-run prints the unified diff of the removal. For a plaintext credential, the diff holds the value of the credential. The value then reaches the terminal, the scroll-back, a CI log or any tool that captures the output. The live run shows no value, and the copies hold ***REDACTED*** after #2645. The preview must show no value either.

Acceptance criteria

Requirement: Dry-run diff redacts a credential value

The dry run of devops config unset SHALL show ***REDACTED*** in place of the value of a key in _SECRET_FIELDS and no text of that value.

Scenario: Dry run of a credential key

  • WHEN The config file holds ai.api_key: sk-ant-fake123 and the user runs devops config unset ai.api_key --dry-run.
  • THEN The diff holds the line of ai.api_key with ***REDACTED*** in place of sk-ant-fake123, and no line of the diff holds sk-ant-fake123.

Requirement: Dry-run diff shows a non-credential value

The dry run of devops config unset SHALL show the value of a key that is not in _SECRET_FIELDS as the file writes it.

Scenario: Dry run of a non-credential key

  • WHEN The config file holds ai.model: llama3 and the user runs devops config unset ai.model --dry-run.
  • THEN The diff line for ai.model holds llama3.

Requirement: Live removal is unchanged

The live run of devops config unset SHALL remove the key, redact the value in the copy, and print the key, the file and the line with no value.

Scenario: Live removal of a credential key

  • WHEN The config file holds ai.api_key: sk-ant-fake123 and the user runs devops config unset ai.api_key with no --dry-run.
  • THEN The key is gone from the file, the .bak-* copy holds ***REDACTED***, and the output names the key, the file and the line and holds no sk-ant-fake123.

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers the redaction of one value in a unified diff. The diff comes from difflib.unified_diff inside the command. The change reuses the project's own redaction from #2645. The written cost is about 40,000 tokens to build and test the redaction step. Each later fix costs about 2,000 tokens, and the elapsed time is about half a day.

Key questions

  • How does the fix redact the credential value in the dry-run diff?: Redact the removed credential values in the source text, then compute the diff between that redacted text and the content with the key removed. Reuse the redaction that fix(config): devops config unset leaves the plaintext secret that it removes in its .bak copy #2645 added for the copies. Every line of the diff is then safe, and one implementation and one placeholder serve the copies and the diff. (best practice) [sources: src/devops_cli/config/settings.py, src/devops_cli/config/write_history.py, src/devops_cli/models/config.py]
    • Chosen: Redact the source text with the fix(config): devops config unset leaves the plaintext secret that it removes in its .bak copy #2645 redaction before the diff. It covers the removed key and every credential that the removal takes out, and it keeps one placeholder and one implementation. The copies already use it.
    • Rejected: Set the removed key to ***REDACTED*** with round_trip.edit and diff that text. It handles the line of the removed key only. A removed section that holds a credential, or a value that spans lines, keeps the value in the diff.
    • Rejected: Post-process the diff lines. It must parse each line to find the value, so a quoted or multi-line value escapes. It also needs a second redaction implementation.
    • Rejected: Print no diff for a credential key. The preview must still show the key, the file and the line. A suppressed diff loses that.
  • Which keys hold a credential that the preview must redact?: The keys in _SECRET_FIELDS, the frozenset that secret_keys() builds from CREDENTIALS in config/env.py. The live run redacts the copies with the same set, through write_history.credential_paths. [sources: src/devops_cli/config/settings.py, src/devops_cli/config/env.py]
  • Does the fix depend on fix(config): devops config unset leaves the plaintext secret that it removes in its .bak copy #2645?: No. fix(config): devops config unset leaves the plaintext secret that it removes in its .bak copy #2645 changed the copies, and its code is in _write_content and write_history at the base commit. This change redacts the diff text in remove_config_key, and it reads the same redaction. One pull request delivers it. [sources: src/devops_cli/config/settings.py, src/devops_cli/config/write_history.py]
  • Where does the fix redact the value: in the model or in the command that prints the preview?: In remove_config_key, before it builds the diff. ConfigKeyRemoval.diff is the one value that the preview and the JSON output print, so a fix there covers every consumer. A fix in a renderer leaves the other consumers unsafe. (best practice) [sources: src/devops_cli/config/settings.py, src/devops_cli/models/config.py]
    • Chosen: Redact in remove_config_key before the diff. The model field is the one source of the preview. Every consumer of diff is then safe.
    • Rejected: Redact in the command that renders the preview. It leaves the value in the model field, so another consumer or a later renderer prints it again.

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
    scope/config
    status/new
    value/high
    effort/low
    on Oct 30, 2026
  2. dan-petty commented on Oct 30, 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. A credential value is printed to stdout and can reach CI logs or scrollback, but only in a user-invoked preview mode.
    • Value: High. Leaking a plaintext credential to the terminal or a CI log is a direct security exposure for the user.
    • Effort: Low. The fix is a targeted redaction in the dry-run diff rendering, analogous to what #2645 already does for the .bak copy.
    • Related: fix(config): devops config unset leaves the plaintext secret that it removes in its .bak copy #2645, which asks for a different change. Both fix credential leakage from devops config unset. #2645 redacts the .bak file copy; this candidate redacts the --dry-run console preview. Same area, different output surface.
  3. added
    priority/p2-medium
    on Oct 30, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 30, 2026
  5. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

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

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

    @devops-cli-service
    Contributor

    Staged: branch fix/2740-devops-config-unset-dry-run-prints, draft pull request #3158. 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. Redact credential values in the unset dry-run diff: 19001 tokens
  7. dan-petty commented on Nov 2, 2026

    @dan-petty
    OwnerAuthor

    returned per agent request

  8. added
    status/new
    and removed
    status/ready
    on Nov 2, 2026
  9. added
    status/ready
    and removed
    status/new
    on Nov 2, 2026
  10. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

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

  11. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Tool: none found

    Lacks:

    • A tool that redacts exactly the values of the project's own secret-key set (_SECRET_FIELDS) inside a unified diff, while leaving non-credential values as the file writes them.
    • The text-redaction packages found (redact-secret, pyveil) mask secret-looking strings by pattern for logs and prompts; they do not know which YAML key is a credential, so they miss a credential value that matches no known pattern and can mask a non-credential value.
    • The required behavior is a preview that still shows the key, the file and the line, uses the placeholder ***REDACTED***, and reuses the redaction fix(config): devops config unset leaves the plaintext secret that it removes in its .bak copy #2645 added for the .bak copies — a project-internal change in remove_config_key, not a library feature.
    • difflib.unified_diff itself only computes the delta and emits the removed line verbatim; it offers no redaction of the line content.

    Searches run:

    • python library redact secrets values in unified diff output
    • python library redact sensitive values from text config yaml placeholder
    • python package mask secret values in YAML config by key name redaction
    • detect-secrets redact secrets from text output library
    • "redact" python library pypi replace secret values with placeholder keep key

    Sources:

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

  12. dan-petty commented on Nov 4, 2026

    @dan-petty
    OwnerAuthor

    #3218 supersedes this item, so this item closes as not planned. The body of #3218 and openspec/changes/3218-config-unset-with-dry-run-deletes/proposal.md both say so. Its plan covers single keys, block scalars and removed sections.

    This item has no symptom today. unset_value calls remove_config_key(key, dry_run=False) at src/devops_cli/commands/config.py:331 and prints no preview. #3218 restores the preview with a redacted diff. PR #3158, the plan of this item, closed unmerged with the comment "Rejected" on 2026-11-02.

    What moved: the requirements on redaction, on the value of a key that is not a credential and on the live run are in the plan of #3218. One case was not in that plan: a comment line that holds the credential value. A comment on #3218 states the amendment that its tasks 1.1 and 1.2 and its spec delta need.

    The status of this item stops a second plan, which would conflict with #3218. This item has no change folder and no open pull request.

  13. removed
    status/ready
    on Nov 4, 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/lowpriority/p2-mediumscope/configsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions