Skip to content

fix(cli): use click.Choice in cf proof capture (#723)#795

Merged
frankbria merged 2 commits into
mainfrom
fix/p0.12-proof-capture-choice
Jul 3, 2026
Merged

fix(cli): use click.Choice in cf proof capture (#723)#795
frankbria merged 2 commits into
mainfrom
fix/p0.12-proof-capture-choice

Conversation

@frankbria

Copy link
Copy Markdown
Owner

What & why

The interactive cf proof capture path prompted for severity and source with type=typer.Choice([...]) — but typer has no Choice (only click.Choice). So any cf proof capture run without --severity/--source raised AttributeError with an uncaught traceback, breaking the command's own documented interactive usage.

Fixes #723 [P0.12].

Change

import click and use click.Choice at both prompt sites. typer.prompt delegates to click.prompt, which accepts a click.Choice type, so the interactive input is now constrained correctly.

Tests

test_capture_interactive_prompts_do_not_crash drives the interactive branch (title/description/where via flags, severity+source via stdin) and asserts a clean capture (exit 0, REQ-0001, severity persisted). This is the branch existing tests skipped (they always pass --severity/--source). 18 passed. ruff + mypy clean.

Demo

$ printf 'high\nqa\n' | cf proof capture --title "Login bug" --description "..." --where src/auth.py
  Obligations: unit, contract
  Generated test stubs: unit: 15 lines, contract: 9 lines
EXIT=0        # was: AttributeError traceback

Acceptance criteria

  • Interactive cf proof capture prompts for severity/source without crashing (click.Choice)
  • A CLI test drives the interactive branch

…exist) (#723)

The interactive capture path prompted severity/source with type=typer.Choice(),
but typer has no Choice attribute — any 'cf proof capture' run without
--severity/--source raised AttributeError with an uncaught traceback, breaking
the command's own documented interactive usage. typer.prompt delegates to
click.prompt, so use click.Choice.

Closes #723
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 9 seconds

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 02bbe93a-69c0-49e6-b065-d5a204101835

📥 Commits

Reviewing files that changed from the base of the PR and between 6760473 and fae7567.

📒 Files selected for processing (2)
  • codeframe/cli/proof_commands.py
  • tests/cli/test_proof_commands.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/p0.12-proof-capture-choice

Comment @coderabbitai help to get the list of available commands.

@claude

claude Bot commented Jul 3, 2026

Copy link
Copy Markdown

Code Review

Summary: Targeted P0 bug fix — replaces the nonexistent typer.Choice with click.Choice at the two interactive prompt sites in cf proof capture. Clean, correct, and minimal.


What's right

  • Root cause is correctly identified. typer.prompt delegates to click.prompt under the hood, so passing click.Choice is the proper fix. No workaround or monkey-patching needed.
  • Import order is correct. import click lands before import typer, maintaining alphabetical order.
  • Comment is placed well. The inline comment on the first prompt explains the non-obvious "why" (per project convention) — the second prompt doesn't repeat it, which is appropriate.
  • Test covers the previously-skipped branch. Driving severity+source via input="high\nqa\n" hits exactly the interactive path that was broken, and the docstring ties it back to [P0.12] Fix cf proof capture hard crash (typer.Choice does not exist) #723.
  • Assertions are meaningful. exit_code == 0, REQ-0001 in output, and req.severity.value == "high" all confirm the fix actually worked end-to-end.

Minor nit

The test asserts severity is persisted but doesn't assert source. Given that source was equally broken (same typer.Choice call), a one-liner sanity check would make the regression coverage complete:

assert req.source.value == "qa"   # or however source is typed on the model

Not a blocker — the crash-path is already proven fixed — but it would close the loop on both repaired sites.


Verdict

Approve. The fix is correct, the change is minimal, and the test exercises the exact failure mode. The nit above is optional hardening, not a requirement for merge.

@frankbria

Copy link
Copy Markdown
Owner Author

Thanks — added assert req.source.value == 'qa' so the test covers both repaired Choice sites (severity + source), not just severity.

@claude

claude Bot commented Jul 3, 2026

Copy link
Copy Markdown

The assert req.source.value == 'qa' addition closes the loop on both repaired sites — thanks for the quick follow-up.

One remaining nit I missed in the first pass: the rest of the CLI passes case_sensitive=False to every click.Choice (e.g. lines 2351, 2357, 3502, 3694, 3700 in app.py). The two new calls here default to case_sensitive=True, so typing High or QA at the interactive prompt will return an "Invalid value" error rather than accepting input. Low priority but worth keeping consistent before merge:

type=click.Choice(["critical", "high", "medium", "low"], case_sensitive=False),
# and
type=click.Choice(["production", "qa", "dogfooding", "monitoring", "user_report"], case_sensitive=False),

Otherwise this is ready to go.

@frankbria frankbria merged commit 0920ded into main Jul 3, 2026
11 checks passed
@frankbria frankbria deleted the fix/p0.12-proof-capture-choice branch July 3, 2026 06:54
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