Skip to content

ctr: preserve args after "-" in images export - #14217

Merged
mxpv merged 1 commit into
containerd:mainfrom
samuelkarp:ctr-stop-on-nth-arg
Sep 24, 2026
Merged

mxpv merged 1 commit into
containerd:mainfrom
samuelkarp:ctr-stop-on-nth-arg

Conversation

@samuelkarp

Copy link
Copy Markdown
Member

urfave/cli/v3 breaks out of its flag parsing loop when it encounters a "-" positional argument without appending the remaining arguments, causing "ctr images export - " to drop all image references and flags following "-".

When is "-", recover the un-truncated arguments from the parent "images" command lineage and re-parse the tail starting at "-" with a sentinel placeholder so trailing image references and flags are preserved.

This workaround can be removed after the bug is fixed upstream:

Assisted-by: Antigravity

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.

Copilot review overview

🟡 Changes recommended

The argument reconstruction must preserve preceding flags and -- separator semantics.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds a workaround for preserving arguments after - in ctr images export, with regression tests.

Changes:

  • Reconstructs and reparses arguments for stdout exports.
  • Adds tests for trailing images and flags.
File Summary
cmd/​ctr/​commands/​images/​export.go Implements argument recovery; reparsing currently drops preceding flags and mishandles -- before the output dash.
cmd/​ctr/​commands/​images/​export_test.go Adds regression coverage for dash-output argument handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/ctr/commands/images/export.go Resolved
Comment thread cmd/ctr/commands/images/export.go Resolved
urfave/cli/v3 breaks out of its flag parsing loop when it encounters a
"-" positional argument without appending the remaining arguments,
causing "ctr images export - <image>" to drop all image references and
flags following "-".

When <out> is "-", recover the un-truncated arguments from the parent
"images" command lineage and re-parse the tail starting at "-" with a
sentinel placeholder so trailing image references and flags are
preserved.

This workaround can be removed after the bug is fixed upstream:

* urfave/cli#2418
* urfave/cli#2419

Assisted-by: Antigravity
Signed-off-by: Samuel Karp <[email protected]>
Copilot AI review requested due to automatic review settings September 23, 2026 23:52

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.

Copilot review overview

🔵 Needs a closer look

Reparsing currently drops flags before the output dash; preserve the full argument prefix.

Review effort: Lite
Findings: None

Resolved since last review (1)

@thaJeztah thaJeztah 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.

LGTM

Sorry for causing these with my v3 bump! (I guess the positive side is that we found missing coverage)

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Sep 24, 2026
@mxpv
mxpv added this pull request to the merge queue Sep 24, 2026
@thaJeztah

Copy link
Copy Markdown
Member

/cherry-pick release/2.4

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@thaJeztah: once the present PR merges, I will cherry-pick it on top of release/2.4 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release/2.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Merged via the queue into containerd:main with commit e210d84 Sep 24, 2026
55 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Sep 24, 2026
@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@thaJeztah: new pull request created: #14219

Details

In response to this:

/cherry-pick release/2.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/2.4.x PR commits are cherry picked into release/2.4 branch size/L

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants