Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-02
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Design

## Decisions

- **Redact the source text before the diff.**: Every diff line comes from redacted text, so no post-processing can miss a value.
- **Use `***REDACTED***` as the placeholder.**: It is the placeholder that #2645 uses in file copies.
- **Use `round_trip.edit` to set the credential to the placeholder.**: It edits the YAML value in place and keeps comments and other lines.
- **Keep non-credential values in the diff.**: The preview must still show what the removal changes.
- **Leave the live run path unchanged.**: The live run already redacts copies and prints no value.

## Rejected alternatives

- **Post-process each diff line.**: A value can span lines or contain the key name. Parsing YAML diff lines is fragile.
- **Suppress the diff for credential keys.**: The preview must show the key, file and line. The issue requires a placeholder.
- **Redact every value in the diff.**: The issue requires non-credential values such as `ai.model: llama3` to show.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Proposal

## Why

The dry-run preview of `devops config unset` prints the credential value in its diff. #2740 reports that the value reaches terminals, scroll-back and CI logs. The change redacts the value in the preview.

## What Changes

- Redact the credential value in the dry-run diff before `difflib.unified_diff` runs.
- Keep non-credential values in the dry-run preview.
- Add a test for a credential key and a non-credential key.
- Update the command help and the model description to state that the preview redacts credentials.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `config-commands`: Dry-run diff redacts credential values

## Impact

- Code: `src/devops_cli/config/settings.py`, `src/devops_cli/models/config.py`, `src/devops_cli/commands/config.py`
- Tests: `tests/config/test_config_unset_dry_run_redaction.py`

## Feasibility

- The inputs confirm the premise: `remove_config_key` in `src/devops_cli/config/settings.py` builds the diff from `text.splitlines()` and `content.splitlines()` with no redaction.
- `_SECRET_FIELDS` is in `src/devops_cli/config/settings.py`, and `write_history.credential_paths` redacts only the backup copy.
- The first check is `uv run devops ci test tests/config/test_config_unset_dry_run_redaction.py`.
- The next check uses a temporary `HOME` and `PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring`: `uv run devops config unset ai.api_key --dry-run`.
- A second manual check uses `uv run devops config unset ai.model --dry-run` and expects `llama3` in the diff.

## Existing Tool Considered

No open, maintained tool covers redacting one value in a `difflib.unified_diff` inside this CLI. The change builds its own code: about 2,000 tokens to build, 500 to keep and 1,000 to fix, and under one hour. It deletes no internal code.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## ADDED Requirements

### Requirement: Dry-run diff redacts credential values
When `devops config unset <key> --dry-run` removes a key whose name is a credential, the diff SHALL show `***REDACTED***` in place of the value.

#### Scenario: Credential value is redacted in the dry-run diff
- **WHEN** A config file holds `ai.api_key: sk-ant-fake123` and the user runs `devops config unset ai.api_key --dry-run`
- **THEN** The diff line for the removed key shows `***REDACTED***`, and no line of the diff holds `sk-ant-fake123`.

#### Scenario: Non-credential value stays in the dry-run diff
- **WHEN** A config file holds `ai.model: llama3` and the user runs `devops config unset ai.model --dry-run`
- **THEN** The diff line for the removed key shows `llama3`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Tasks

## 1. Redact credential values in the unset dry-run diff

Reads: `src/devops_cli/config/settings.py`, `src/devops_cli/config/env.py`, `src/devops_cli/models/config.py`, `src/devops_cli/commands/config.py`. Changes: `src/devops_cli/config/settings.py`, `src/devops_cli/models/config.py`, `src/devops_cli/commands/config.py`, `tests/config/test_config_unset_dry_run_redaction.py` (new).

- [ ] 1.1 Write `tests/config/test_config_unset_dry_run_redaction.py` first. It calls `remove_config_key('ai.api_key', target_path=tmp_path/'config.yaml', dry_run=True)` on a file holding `ai.api_key: sk-ant-fake123` and asserts the diff holds `***REDACTED***` and not `sk-ant-fake123`. It also calls the same function for `ai.model: llama3` and asserts the diff holds `llama3`, and verify that `uv run devops ci test tests/config/test_config_unset_dry_run_redaction.py` fails on the base
- [ ] 1.2 In `remove_config_key` in `src/devops_cli/config/settings.py`, after `round_trip.find` returns `path` and `line`, build `diff_text` from `text`. When `path` is in `_SECRET_FIELDS`, set the value at `path` in `diff_text` to `***REDACTED***` with `round_trip.edit`. Compute `difflib.unified_diff` from `diff_text.splitlines()` and `content.splitlines()`. Keep `content` from the original `text`. Update the `diff` field description in `src/devops_cli/models/config.py` and the `unset` help in `src/devops_cli/commands/config.py` to state that the preview redacts credentials, and verify that `uv run devops ci test tests/config/test_config_unset_dry_run_redaction.py` passes

## Workflow follow-up

- Pending a person: review the diff in tuicr (tuicr -r <base>..HEAD).