Skip to content

fix: warn about overwriting in blob sign only when the signature file exists - #1381

Open
RaphaelFakhri wants to merge 1 commit into
notaryproject:mainfrom
RaphaelFakhri:fix/blob-sign-force-warning
Open

RaphaelFakhri wants to merge 1 commit into
notaryproject:mainfrom
RaphaelFakhri:fix/blob-sign-force-warning

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

What this PR does

notation blob sign --force prints Warning: existing signature file will be overwritten even when no signature file exists at the target path. The --force branch skips the existence check that the prompt branch uses.

This PR checks for an existing signature file first, then either prompts (without --force) or prints the warning (with --force). This matches notation blob policy import and notation blob policy init, which warn only when a configuration already exists.

It also removes a stray space after the newline in the success message. Before this change, the output was:

Successfully signed /tmp/my-blob.bin
 Signature file written to /tmp/my-blob.bin.jws.sig

The output now matches specs/cmd/blob.md.

Testing

TestBlobSignCommand_ForceOutput signs a blob twice with --force using a generated self-signed key:

  • First run: no signature file exists. The test checks for no overwrite warning and exact stdout.
  • Second run: the signature file exists. The test checks for the overwrite warning.

Without the fix, the test fails on the stray space, and with only the space fix applied, it fails on the spurious warning. With the fix, it passes.

go test ./cmd/notation/blob/ -run TestBlobSignCommand_ForceOutput -v

Fixes #1380

… exists

notation blob sign --force printed "Warning: existing signature file will
be overwritten" even when no signature file existed. The success message
also printed a stray space at the start of the "Signature file written to"
line.

Print the overwrite warning only when the signature file exists, and remove
the stray space.

Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 10:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

notation blob sign --force warns about overwriting a signature file that does not exist

2 participants