Skip to content

AI spam#3551

Closed
Tatlatat wants to merge 1 commit into
pallets:mainfrom
Tatlatat:fix-2614-resilient-default
Closed

AI spam#3551
Tatlatat wants to merge 1 commit into
pallets:mainfrom
Tatlatat:fix-2614-resilient-default

Conversation

@Tatlatat

@Tatlatat Tatlatat commented Jun 3, 2026

Copy link
Copy Markdown

Fixes #2614

Parameter.consume_value sourced the parameter's default value unconditionally. As a result, default callbacks (and other defaults) were evaluated even during shell completion, where ctx.resilient_parsing is enabled.

The Context.resilient_parsing docs state that in this mode "Default values will also be ignored. This is useful for implementing things such as completion support." This change honors that flag when sourcing the default, so expensive default callbacks are no longer called while generating completions.

Changes

  • consume_value only applies the parameter default when not ctx.resilient_parsing.
  • Added a test that fails without the change: a default callback must not run while ShellComplete generates completions.
  • CHANGES.rst entry and a .. versionchanged:: note.

The full test suite passes (1668 passed, 0 regressions).

Parameter.consume_value pulled the parameter default unconditionally, so
default callbacks (and other defaults) were evaluated even when
ctx.resilient_parsing was enabled during shell completion. The docs state
that defaults are ignored in resilient parsing mode. Honor that flag when
sourcing the default value.

fixes pallets#2614
@davidism davidism closed this Jun 3, 2026
@davidism davidism changed the title Don't evaluate parameter defaults during shell completion AI spam Jun 3, 2026
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.

Click evaluates default callbacks during tab-completion

2 participants