Skip to content

fix(vcr/verifier): handle unparseable issuer DID instead of nil deref#4247

Open
SAY-5 wants to merge 2 commits into
nuts-foundation:masterfrom
SAY-5:fix/verifier-nil-issuer-did-4235
Open

fix(vcr/verifier): handle unparseable issuer DID instead of nil deref#4247
SAY-5 wants to merge 2 commits into
nuts-foundation:masterfrom
SAY-5:fix/verifier-nil-issuer-did-4235

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 12, 2026

Closes #4235

Verify discarded the error from did.ParseDID(credentialToVerify.Issuer.String()) and then dereferenced the resulting (possibly nil) *did.DID at v.didResolver.Resolve(*issuerDID, &metadata), panicking the node when an external issuer emitted a non-RFC3986 did:x509.

Surface the parse error as a regular validation failure ("could not validate issuer: ...") so the request fails cleanly with a 4xx instead of crashing the verifier goroutine.

Added a regression test under TestVerifier_Verify/with_signature_check that wraps the call in require.NotPanics and asserts the error is surfaced. The test panics on master and passes with this change.

@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented May 12, 2026

Qlty


Coverage Impact

⬇️ Merging this pull request will decrease total coverage on master by 0.09%.

Modified Files with Diff Coverage (1)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
vcr/verifier/verifier.go100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

Copy link
Copy Markdown
Member

@reinkrul reinkrul left a comment

Choose a reason for hiding this comment

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

@SAY-5 this repository requires signed commits, I can't merge otherwise

Comment thread vcr/verifier/verifier.go Outdated
issuerDID, _ := did.ParseDID(credentialToVerify.Issuer.String())
issuerDID, err := did.ParseDID(credentialToVerify.Issuer.String())
if err != nil {
return fmt.Errorf("could not validate issuer: %w", err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("could not validate issuer: %w", err)
return fmt.Errorf("could not parse issuer: %w", err)

Comment thread vcr/verifier/verifier_test.go Outdated
require.NotPanics(t, func() {
validationErr := ctx.verifier.Verify(malformed, true, true, nil)
assert.Error(t, validationErr)
assert.Contains(t, validationErr.Error(), "could not validate issuer")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
assert.Contains(t, validationErr.Error(), "could not validate issuer")
assert.Contains(t, validationErr.Error(), "could not parse issuer")

@SAY-5
Copy link
Copy Markdown
Author

SAY-5 commented May 12, 2026

Thanks for the heads up. I'll re-sign the commits with a verified GPG key and force-push the updated branch shortly.

@SAY-5 SAY-5 force-pushed the fix/verifier-nil-issuer-did-4235 branch from 8b8565f to c22d536 Compare May 13, 2026 19:46
@SAY-5
Copy link
Copy Markdown
Author

SAY-5 commented May 13, 2026

Applied both suggestions in c22d536: the parse-error path now reads could not parse issuer and the test asserts on that message. go test ./vcr/verifier/... is green. The commit is SSH-signed but the signing key on this account is not yet registered as a verified signing key on github.com, so GitHub still shows it as unverified. Will get the SSH signing public key added under Settings -> SSH and GPG keys -> Signing key shortly so the verification badge flips on.

@SAY-5
Copy link
Copy Markdown
Author

SAY-5 commented May 13, 2026

Applied both suggestions, the parse-path error now says 'could not parse issuer' and the assertion was updated to match. Pushed 2ce91f9.

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.

vcr/verifier: nil-pointer panic on unparseable issuer DID

2 participants