Skip to content

Do not copy unused options on --insert - #5136

Open
Zinkelburger wants to merge 1 commit into
teemtee:mainfrom
Zinkelburger:insert-omit-unused-cli-defaults
Open

Do not copy unused options on --insert#5136
Zinkelburger wants to merge 1 commit into
teemtee:mainfrom
Zinkelburger:insert-omit-unused-cli-defaults

Conversation

@Zinkelburger

Copy link
Copy Markdown

Click fills every step option with its default, so discover --insert
was copying all options into the new phase, including repository: None
and revision: None. tmt then warned that those deprecated keys were in
use even though the caller only passed --url/--ref:

$ tmt run discover --insert --how fmf --url ... --ref ...
warn: Field 'repository' is deprecated, use 'url' instead.
warn: Field 'revision' is deprecated, use 'ref' instead.

This is how Testing Farm invokes tmt for kernelinstall, so every such
run produced false warnings.

_to_raw_step_datum() now only copies options whose Click
ParameterSource is COMMANDLINE or ENVIRONMENT, which is the same
filter --update already applies in _patch_raw_datum(). An option
that is genuinely passed (e.g. an explicit --repository) still lands
in the phase and still warns.

Pull Request Checklist

  • implement the feature
  • [-] write the documentation (not needed, no docs describe --insert copying defaults)
  • extend the test coverage
  • [-] update the specification (not needed, no spec change)
  • [-] adjust plugin docstring (not needed, not a plugin change)
  • [-] modify the json schema (not needed, schema unchanged)
  • [-] mention the version (not needed, fixes a bug)
  • include a release note

@LecrisUT LecrisUT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I defer the review to someone who has touched those things. Reading the code around that section looks like it is getting way too over-engineered.

Comment thread tmt/steps/__init__.py
Comment on lines 1158 to 1172
def _iter_options() -> Iterator[tuple[str, Any]]:
for name, value in options.items():
if name in ('update', 'update_missing', 'insert', 'allowed-how'):
for name, value in invocation.options.items():
if name in ('update', 'update_missing', 'insert', 'allowed_how'):
continue

value_source = invocation.option_sources.get(name)
if value_source not in (
ParameterSource.COMMANDLINE,
ParameterSource.ENVIRONMENT,
):
debug4(f'{name} not really given via CLI/env, omit from raw step datum')
continue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looks ok to me, but it seems like we are dancing around something that could/should have been much simpler

@LecrisUT
LecrisUT requested review from happz and psss August 21, 2026 03:24
Click fills every discover option with a default, so --insert was
writing repository and revision as unused None into the new phase.
That made tmt warn about deprecated keys even when callers used url
and ref, as Testing Farm does for kernelinstall.

Only copy options that were really given on the command line or via
environment. The filter now lives in a single place,
_to_raw_step_datum(), so _patch_raw_datum() no longer needs to consult
Click and only handles --update-missing semantics. Also fix the skip
list to use 'allowed_how', the Click parameter name, instead of
'allowed-how' which never matched.

Assisted-by: Cursor
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WooXbhjvXNBanpvtVD84Mi
@Zinkelburger
Zinkelburger force-pushed the insert-omit-unused-cli-defaults branch from 821ac56 to 98208e9 Compare August 21, 2026 15:44
@github-project-automation github-project-automation Bot moved this to backlog in planning Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: backlog

Development

Successfully merging this pull request may close these issues.

3 participants