Repository navigation
fix(proto): improve unsupported key and algorithm error messages - #603
Merged
yizha1 merged 1 commit intoNov 30, 2026
Merged
Conversation
Integer-backed key types, key sizes, and signing algorithms were formatted with %q, causing rejected values to appear as Unicode characters rather than useful diagnostics. Name RSA and EC key types, label key sizes in bits, and retain decimal values for unknown key types and signing algorithms. Share key-specification error formatting between both conversion functions. Add assertions for supported conversions and error messages for unsupported key sizes, unknown key types, and unknown signing algorithms. Accepted inputs and returned values are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3a297bdb-d8ae-492d-bae7-d555afa73630 Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
cshung
requested review from
NiazFK,
gokarnm,
priteshbandi,
rgnote,
shizhMSFT,
toddysm,
vaninrao10 and
yizha1
as code owners
November 30, 2026 18:35
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the clearer key and algorithm diagnostics and accompanying test updates.
No open issues 🎉
What changed in this PR
This PR improves diagnostics for unsupported keys and signing algorithms in the plugin protocol conversion layer, without changing accepted inputs or successful return values. The fix is independent of the dependency upgrade in #598.
Changes:
- Share key-specification error formatting with readable RSA/EC names, decimal unknown types, and sizes labeled in bits; report unsupported algorithm IDs in decimal.
- Extend tests to assert exact error messages for invalid inputs and confirm supported conversions return no errors.
| File | Description |
|---|---|
plugin/proto/algorithm.go |
Replaces character-formatted errors with readable key and algorithm diagnostics. |
plugin/proto/algorithm_test.go |
Adds error assertions for unsupported sizes, unknown types and algorithms, and zero values. |
Review effort: Balanced
yizha1
approved these changes
Nov 30, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #603 +/- ##
==========================================
+ Coverage 82.88% 82.94% +0.06%
==========================================
Files 36 36
Lines 2635 2645 +10
==========================================
+ Hits 2184 2194 +10
Misses 310 310
Partials 141 141 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The error paths in
EncodeKeySpec,HashAlgorithmFromKeySpec, andEncodeSigningAlgorithmformat integer-backed values with%q. This renders rejected key types, key sizes, and algorithm IDs as Unicode characters rather than meaningful diagnostic values. For example, an RSA key with size 1234 producesinvalid KeySpec {'\x01' 'Ӓ'}.This change reports named RSA/EC key types and labeled sizes in bits, with decimal values for unknown key types and signing algorithms:
Both key-specification conversion functions share the error formatting. Tests assert the diagnostic messages for unsupported RSA/EC sizes, unknown key types, zero values, and unknown algorithms, while retaining the existing supported-conversion cases.
This intentionally changes error text, but does not change accepted inputs or successful return values. No dependencies or registry mocks are changed.
Motivation
This is a pre-existing formatting bug exposed by the Go 1.26 vet checks when the module declares Go 1.26, as proposed in #598. The same character-formatted output was reproduced with Go 1.23, 1.24, and 1.26. The repair is independent of the ORAS upgrade and works with the existing Go 1.23 minimum and ORAS 2.6.0 dependency.
Related: #598.
Validation
./plugin/prototests passed.go vet ./...passed.git diff --checkpassed.These are local results; PR CI will provide the upstream checks.