Surface DID resolution errors in VP verification failures#3979
Surface DID resolution errors in VP verification failures#3979
Conversation
|
Coverage Impact ⬆️ Merging this pull request will increase total coverage on Modified Files with Diff Coverage (4)
🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 Help
|
1 new issue
|
8aa2b43 to
3e58304
Compare
| return nil, oauth.OAuth2Error{ | ||
| Code: oauth.InvalidRequest, | ||
| Description: "presentation(s) or contained credential(s) are invalid", | ||
| Description: verificationErrorDescription(err), |
There was a problem hiding this comment.
Why the wrapper? Would the err.Error() not be sufficient?
stevenvegt
left a comment
There was a problem hiding this comment.
this whole thing feels like a band aid. The moment a new one gets introduced, this thing falls back on the default. My gut feeling is going up the chain and catch the errors and map them to the correct ones. Or, create a factory for a oauth.OAuth2Error which accepts all kind of errors and creates the correct object.
That said, it is covered in tests and is an improvement to the current situation. So.. let me know if you disagree and I will hit the accept button :)
I'll rework it to something more comprehensive. |

Plan: Improve Client Error Message for DID Resolution Failures
Summary of Changes
Problem: Currently, when the server can't resolve a DID document during VP verification, it returns a generic error: "presentation(s) or contained credential(s) are invalid". This makes troubleshooting difficult for clients.
Solution Implemented:
Created
verificationErrorDescription()helper (auth/api/iam/openid4vp.go):errors.Is()and string pattern matchingUpdated error handling in two locations:
auth/api/iam/openid4vp.go- OpenID4VP HandleAuthorizeResponse flowauth/api/iam/s2s_vptoken.go- Service-to-service VP token verification flowAdded comprehensive tests (
auth/api/iam/openid4vp_test.go):New Error Messages:
Review Feedback Addressed:
err.Error()directly instead of custom messagesTesting Results:
Security Considerations:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.