Skip to content

fix(keyservice): return error for unsupported master key types#2220

Open
santosh7676 wants to merge 2 commits into
getsops:mainfrom
santosh7676:fix/keyservice-unsupported-master-key-panic
Open

fix(keyservice): return error for unsupported master key types#2220
santosh7676 wants to merge 2 commits into
getsops:mainfrom
santosh7676:fix/keyservice-unsupported-master-key-panic

Conversation

@santosh7676

Copy link
Copy Markdown

Summary

  • Replace panic in keyservice.KeyFromMasterKey when encountering an unknown keys.MasterKey type with explicit error handling.
  • Add KeyFromMasterKeyOrError and ErrUnsupportedMasterKeyType for callers that need to handle unsupported key types safely.
  • Update core encrypt/decrypt paths in sops.go to propagate conversion errors instead of crashing the process.
  • Add regression tests to ensure unsupported key types return an error and do not panic.

KeyFromMasterKey previously panicked on unknown master key types. That can crash SOPS during encrypt/decrypt operations instead of returning a recoverable error. This change makes failure behavior consistent with the rest of the key handling flow.

Behavior change

  • Before: unsupported MasterKey type -> process panic.
  • After: unsupported MasterKey type -> returned error (ErrUnsupportedMasterKeyType) and normal error propagation in encrypt/decrypt paths.

Signed-off-by: Santosh Mahale <santoshmahale7676@gmail.com>
@santosh7676 santosh7676 force-pushed the fix/keyservice-unsupported-master-key-panic branch from 492ba3d to 838d779 Compare June 16, 2026 13:33
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.

1 participant