Skip to content

AI junk - #3799

Closed
22elix3r wants to merge 1 commit into
pallets:mainfrom
22elix3r:fix/2853-short-description
Closed

AI junk#3799
22elix3r wants to merge 1 commit into
pallets:mainfrom
22elix3r:fix/2853-short-description

Conversation

@22elix3r

Copy link
Copy Markdown

Summary

Command.main handles shell completion before it enters the ClickException handler. A custom Group.get_command that calls ctx.fail() (the documented alias/prefix pattern) therefore prints a traceback during tab completion instead of the usage error.

Normal invocation of the same prefix already shows Error: Too many matches: ... and exits 2. Completion should do the same.

Related Issue

Fixes #2853

Changes Made

  • Catch ClickException in Command._main_shell_completion, call show(), and exit with the exception's exit code.
  • Successful completion still exits early with the completer's status code.

Testing

  • pytest tests/test_shell_completion.py tests/test_commands.py tests/test_basic.py (265 passed)
  • pytest (1993 passed, 24 skipped, 1 xfailed)
  • ruff check / ruff format on the touched files

Tests use the documented ambiguous-prefix get_command pattern: completion of cli i no longer traceback, and a normal cli i invoke still reports the usage error.

Notes

Completion still uses resilient_parsing for missing commands and invalid values. This only covers exceptions that get_command (or similar) raises on purpose via ctx.fail().

Command.main runs shell completion before its ClickException
handler. A custom Group.get_command that calls ctx.fail() therefore
printed a full traceback instead of the usage error.

Catch ClickException in _main_shell_completion and show it the
same way as a normal invocation.

Fixes pallets#2853

Signed-off-by: elix3r <157088510+22elix3r@users.noreply.github.com>
@davidism

Copy link
Copy Markdown
Member

@davidism davidism closed this Aug 27, 2026
@davidism davidism added the rejected AI Contribution rejected because of its untrustworthy AI origin label Aug 27, 2026
@davidism davidism changed the title Don't dump a traceback for usage errors during completion AI junk Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rejected AI Contribution rejected because of its untrustworthy AI origin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The call stack is displayed when an exception is returned when an invalid parameter is displayed during command line association.

2 participants