Skip to content

Hint that the input is not a sops file when it cannot be loaded - #2329

Open
cvas22 wants to merge 1 commit into
getsops:mainfrom
cvas22:feat/258-non-sops-error
Open

cvas22 wants to merge 1 commit into
getsops:mainfrom
cvas22:feat/258-non-sops-error

Conversation

@cvas22

@cvas22 cvas22 commented Oct 23, 2026

Copy link
Copy Markdown

Fixes #258

Running sops -d on a file that is not a sops file only reported the parser error (for example Could not unmarshal input data: invalid character '#' looking for beginning of value), which gives no hint about the actual problem.

Changes:

  • If loading an encrypted file fails for a reason other than missing metadata, the error now ends with (is the file a sops-encrypted file in the expected format?).
  • sops.MetadataNotFound now reads sops metadata not found: the file does not appear to be encrypted with sops. The value is still the same constant, so err == sops.MetadataNotFound checks (e.g. in filestatus and the store tests) are unaffected.

Tests: added cmd/sops/common/common_test.go covering both cases. go test ./cmd/... ./stores/... . passes.

When an input file cannot be parsed as the expected format or has no
sops metadata, say so in the error message instead of only reporting the
parser error.

Fixes getsops#258

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
@cvas22
cvas22 force-pushed the feat/258-non-sops-error branch from b7de515 to cb7d728 Compare November 6, 2026 04:41
@cvas22

cvas22 commented Nov 19, 2026

Copy link
Copy Markdown
Author

@felixfontein could you review this when you have time? thx

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.

Improve error message when trying to load non-SOPS binary files

1 participant