Skip to content

fix(telemetry): the command span holds no argument value, so a secret given to devops config set never reaches the trace backend - #2028

Merged
dan-petty merged 1 commit into
mainfrom
fix/1996-command-span-no-argument-values
Oct 24, 2026
Merged

dan-petty merged 1 commit into
mainfrom
fix/1996-command-span-no-argument-values

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

A command span recorded each argument of the command, so a credential given to devops config set <key> <value> went to the trace backend. Two places sent it:

  • _delegate in src/devops_cli/main.py put " ".join(effective_args) in the span attribute cli.args, with no mask.
  • OTelTelemetryClient in src/devops_cli/telemetry/tracer.py put mask_secrets(" ".join(sys.argv)) in the resource attribute process.command_line of every trace payload. mask_secrets finds secrets by pattern. For devops config set <key> correct-horse-battery-staple, it keeps the value for 5 of the 13 secret keys: cloudflare.api_token, cloudflare.tunnel_token, runs.index_password, service.webhook_secrets and telemetry.logfire_token.

Evidence: the Tempo data source lists cli.args as a span attribute and process.command_line as a resource attribute. The OpenTelemetry semantic conventions give process.command_args and process.command_line as Opt-In, and say that a producer "SHOULD NOT" collect them by default "unless there is sanitization that excludes sensitive data". A secret pattern does not exclude all sensitive data.

The change:

  • The command span of _delegate has no cli.args. It keeps cli.command and cli.args_count.
  • The resource has no process.command_line.
  • The span of the command that runs (_execute_traced_cli_command in src/devops_cli/core/cli.py) holds Click's command path in cli.command_path, such as devops config set. The command path holds the command names and no argument, as in the config write record of fix(tests): a test that writes a real config.yaml fails at the write and names itself, and every config write keeps a backup and a change record #1921. Thus the trace still names the command that ran.
  • docs/TELEMETRY.md (from src/devops_cli/docs/generator.py) and ARCHITECTURE.md say which attributes describe the command line, and that they hold no argument value.

No dashboard, alert or query under k8s/monitoring/ reads cli.args or process.command_line, so no manifest changes.

Tests: tests/test_otel_command_coverage.py runs set cloudflare.tunnel_token <credential> through _delegate with telemetry export captured. test_no_exported_attribute_holds_an_argument_value finds the credential in no exported payload. It fails on origin/main, and it also fails with only the cli.args change, because the resource held the credential. test_the_command_spans_keep_the_command_path_and_the_argument_count shows that the spans keep cli.command, cli.args_count and cli.command_path.

Two related paths stay as they are; #2024 and #2025 cover them:

  • The message of a usage error can quote an argument (Click's "Got unexpected extra argument ()"), and the tracer records it in error.message. Also, except click.ClickException in _delegate does not catch the errors that Typer 0.27 raises, because Typer has its own copy of Click.
  • A subprocess span holds the first eight arguments of its command (subprocess.cmd and process.command_line, through a secret pattern). A command that passes the arguments of a person to a program, such as devops uv run or devops gh api, puts them there.

Item

Closes #1996

Task file: docs/agent/tasks/task-1996-command-span-holds-no-argument-value.md

… given to devops config set never reaches the trace backend

The command span of `_delegate` put every argument in `cli.args`, with no
mask. The tracer resource put `sys.argv` in `process.command_line`,
through a secret pattern that keeps a credential for 5 of the 13 secret
keys. Both went to the trace backend.

The command span now keeps `cli.command` and `cli.args_count`, and has
no `cli.args`. The resource has no `process.command_line`. The
OpenTelemetry semantic conventions give `process.command_args` and
`process.command_line` as Opt-In for this reason. The span of the
command that runs holds Click's command path (`cli.command_path`, such
as `devops config set`), which holds no argument.

Task file: `docs/agent/tasks/task-1996-command-span-holds-no-argument-value.md`
@dan-petty
dan-petty marked this pull request as ready for review October 24, 2026 00:48
@dan-petty
dan-petty merged commit 8986c97 into main Oct 24, 2026
16 checks passed
@dan-petty
dan-petty deleted the fix/1996-command-span-no-argument-values branch October 24, 2026 00:48
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.

fix(telemetry): the command span holds no argument value, so a secret given to devops config set never reaches the trace backend

1 participant