Skip to content

Capture lossy telemetry flags after positionals (#342) - #362

Open
sdairs wants to merge 1 commit into
issue-321-child-exit-telemetryfrom
issue-342-lossy-positional-flags
Open

Capture lossy telemetry flags after positionals (#342)#362
sdairs wants to merge 1 commit into
issue-321-child-exit-telemetryfrom
issue-342-lossy-positional-flags

Conversation

@sdairs

@sdairs sdairs commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • consume clap-defined positional arguments during failed-parse telemetry capture without recording their values
  • continue capturing later canonical flag names while stopping conservatively at unmatched input and --
  • cover required, optional, variadic, flag-like, and subcommand-like positional cases plus the cloud org usage failed-parse payload

Tests

  • cargo test -p clickhousectl --bin clickhousectl lossy
  • cargo test -p clickhousectl --test telemetry_test failed_parse_after_positional_captures_later_flags_without_values -- --exact
  • cargo test -p clickhousectl
  • cargo clippy -p clickhousectl --all-targets -- -D warnings

Closes #342

@sdairs
sdairs requested review from iskakaushik and rndD as code owners August 5, 2026 11:50
@sdairs sdairs changed the title Capture flags after lossy positionals (#342) Capture lossy telemetry flags after positionals (#342) Aug 5, 2026
@sdairs
sdairs requested a review from Copilot August 5, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a telemetry gap in clickhousectl where failed-parse (“lossy”) telemetry stopped at the first positional argument and therefore missed valid flags that appeared later in argv. It extends the definition-anchored argv walker to consume clap-defined positional slots without recording their values, so it can continue capturing later canonical flag names while still stopping at unknown tokens and -- to preserve privacy guarantees.

Changes:

  • Teach capture_lossy() to advance over positional arguments (including multi-value and hyphenated-value cases) without retaining any positional/flag values.
  • Improve lossy handling for hyphenated tokens (including short clusters) so positional-vs-flag decisions stay conservative and definition-driven.
  • Add both unit tests and an end-to-end regression test covering the cloud org usage ORG_ID --from-date ... --to-date ... reproduction and multiple positional shapes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/clickhousectl/src/telemetry.rs Extends lossy argv walking with a positional cursor so later flags can be captured without ever recording argument values.
crates/clickhousectl/tests/telemetry_test.rs Adds an end-to-end regression test ensuring flags after a positional are captured and secret argument strings never appear in telemetry payloads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sdairs
sdairs force-pushed the issue-342-lossy-positional-flags branch from 2eccd16 to 0487a49 Compare August 5, 2026 18:28
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.

Telemetry: lossy parse capture drops flags after positional arguments

2 participants