Skip to content

docs(openspec): plan #2740 Redact config unset dry-run value - #3158

Closed
devops-cli-service[bot] wants to merge 1 commit into
mainfrom
fix/2740-devops-config-unset-dry-run-prints
Closed

devops-cli-service[bot] wants to merge 1 commit into
mainfrom
fix/2740-devops-config-unset-dry-run-prints

Conversation

@devops-cli-service

Copy link
Copy Markdown
Contributor

Plans #2740

The dry-run preview of devops config unset prints the removed line of a credential with its value. The value reaches the terminal, scroll-back and CI logs. The change redacts the value in the source text before difflib.unified_diff runs. The preview shows ***REDACTED*** for a credential and keeps the value of a non-credential key. The live run keeps its current output and file copies. The change adds a test for both cases and updates the command help. It delivers #2740.

Change: openspec/changes/2740-devops-config-unset-dry-run-prints/

Copy link
Copy Markdown
Owner

Review of the plan for #2740.

CI: not re-checked in detail (PR is open and mergeable_state is clean). Premise: partly verified. remove_config_key (src/devops_cli/config/settings.py:1567) builds the diff from text.splitlines() with no redaction (lines 1597-1604). I could not find the path that prints this diff for --dry-run (see finding 2).

  1. The planned check never matches, and a section removal still leaks. Task 1.2 says "When path is in _SECRET_FIELDS". path is a KeyPath tuple (for example ("ai", "api_key"), from round_trip.find, round_trip.py:183). _SECRET_FIELDS is a frozenset[str] of dotted keys (settings.py:136, from secret_keys()). A tuple is never in that set. The existing live path does it right: write_history.credential_paths(previous, path, _SECRET_FIELDS) (settings.py:1606, write_history.py:120) joins the path and also returns every credential below a removed section. With the plan as written, devops config unset ai --dry-run still prints ai.api_key, because ai is not a secret key. The live run already covers that case (tests/config/test_config_key_removal.py:249, test_a_removal_of_a_section_redacts_each_credential_in_it). Fix: call credential_paths on text and set each returned path to CONST_CONFIG_REDACTED_VALUE (config/constants.py:48) in diff_text; add a test for a section removal. Use the constant, not the literal.
  2. The preview path is not shown. unset_value (src/devops_cli/commands/config.py:313-334) has no dry_run parameter, calls remove_config_key(key, dry_run=False), and never reads removal.diff. @dry_run_class("no-external-request") only sets an attribute (dry_run/decorator.py:22-37). The issue says unset_value passes the lines to render_dry_run_result, but git grep render_dry_run_result origin/main -- src shows no such call in commands/config.py. I did not run the command (read-only review), so whether --dry-run prints the diff, or whether it reaches remove_config_key(dry_run=True) some other way, is not verified. Fix: record in Feasibility the output of the reproduction steps of the issue on current main (the proposal lists them as a plan only). If the CLI never calls the dry run, the change needs a wiring task, and the premise differs from the issue. The spec config-commands/spec.md:156 ("--dry-run writes nothing") expects the diff in the response.
  3. The test does not cover the CLI. Task 1.1 calls remove_config_key(..., dry_run=True) only. That proves the function, not the preview a person sees. Fix: add a command-level test of unset <key> --dry-run whose output holds no value (and fail-on-base for it).
  4. A new test file where one exists. tests/config/test_config_key_removal.py already holds the removal tests, including test_a_dry_run_returns_the_removal_and_writes_nothing (line 119) and the credential tests. Fix: add the two tests there, or say why a new file is needed.
  5. Side effects of round_trip.edit on the source text are not considered. edit re-dumps the YAML (round_trip.py:94-143), so diff_text is a normalized copy, while content is also normalized. The diff then compares two normalized texts, and can hide formatting changes that the live run writes, and can move the line numbers. The existing requirement (config-commands/spec.md:156-161) expects @@ -7 +6,0 @@ and - vllm_url: <value>. Not verified for files with unusual quoting or comments. Fix: add a test for a file with a comment and a quoted value, and say how scrub (edit(..., scrub=...), used for # was <value> comments) applies, since a comment that holds the value is part of the diff too.
  6. Spec delta: ADDED is right for new requirement names, and config-commands exists. Scenario values such as sk-ant-fake123 look like a real key prefix and can trip secret scanners; existing tests use FAKE-2645-value (spec.md:117). Fix: use a clearly fake value. The issue also has a third requirement ("live run unchanged") that has no scenario or test here.
  7. Existing Tool: "2,000 tokens to build, 500 to keep, 1,000 to fix, under one hour" is acceptable. Feasibility bullets 3 to 5 are plans to run, not results.

Related issues: none found open on this code (search for config unset redact returned only #2740).

Verdict: hold until finding 1 (wrong membership test) is fixed and finding 2 (where the preview is printed) is confirmed against the real command.


Generated by Claude Code

Copy link
Copy Markdown
Owner

Premise check of #2740 against current main (24ef67a). The issue cannot be built as written, so I changed nothing in this plan.

Finding 1 of the earlier review is right (a tuple path is never in the _SECRET_FIELDS set of dotted strings; write_history.credential_paths is the correct call). But a deeper problem makes the fix moot:

The preview that the issue wants to redact does not exist on main.

Reproduction on main with a fake config (temporary HOME, ai.api_key: FAKE-2740-secret-value, ai.model: llama3, PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring, no DEVOPS_CLI_CONFIG):

$ devops config unset ai.api_key --dry-run
│ No such option: --dry-run          exit=2

$ devops --dry-run config unset ai.api_key
Removed ai.api_key from <home>/.config/devops-cli/config.yaml:3.
The file before the change is in <home>/.config/devops-cli/config.yaml.bak-20261102-160033.
exit=0
  • No diff and no value is printed in either form, so the leak in the issue does not reproduce.
  • The second run is a different and worse defect: the global --dry-run flag is ignored, and the command deletes the key and writes a backup (the file ends as ai:\n model: llama3; the backup shows '***REDACTED***', as fix(config): devops config unset leaves the plaintext secret that it removes in its .bak copy #2645 intends).
  • tests/commands/test_config.py:158 (test_config_unset_dry_run_runs_as_no_external_request) asserts this behavior: it runs --dry-run config unset ai.vllm_url and expects the line to be gone.
  • The existing requirement openspec/specs/config-commands/spec.md:156 ("devops config unset --dry-run writes nothing", with the diff in the response) is therefore not met by the code.

A plan that redacts removal.diff would change a value that no command prints. A plan that restores the preview is a different item (wire the dry run back, honor the global flag, then redact), with a different premise, spec delta (MODIFIED for the line 156 requirement) and tests. I wrote no compensating plan text.

Proposed next step (a person): devops roadmap return 2740 --comment "<this evidence>" --confirm (it fails with a 401 in my session). Then either reject #2740 as superseded by #2963, or rewrite it as: "devops --dry-run config unset <key> deletes the key and writes a copy; restore the preview with a credential-redacted diff". No open issue covers that defect (search for config unset dry-run returned only #2740). This plan PR should then close unmerged.

Side finding for the plan-PR tooling: pull_form.body_problems refuses the correct body of this plan PR (Plans #2740 plus the Change: line) with "The body has no line Closes #<issue>." The title passes title_problems.


Generated by Claude Code

@dan-petty

Copy link
Copy Markdown
Owner

Rejected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant