fix: treat an absent identifier as empty in CredentialSubjectProbe - #63
Open
wantaekchoi wants to merge 1 commit into
Open
fix: treat an absent identifier as empty in CredentialSubjectProbe#63wantaekchoi wants to merge 1 commit into
wantaekchoi wants to merge 1 commit into
Conversation
asNodeList returns null when the field is missing, so the null branch was reporting the subject as populated and no error was raised. A credentialSubject carrying neither id nor identifier validated clean, which OB 3.0 B.1.3 requires to fail. Adds the fixture the suite was missing for that case.
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.
A
credentialSubjectwith neitheridnoridentifiercurrently validates as VALID. OB 3.0 §B.1.3 says "Eitheridor at least oneidentifierMUST be supplied", and the JSON Schema does not encode that constraint, soCredentialSubjectProbeis the only place it is enforced.Cause
#46 swapped the inline array check for
JsonNodeUtil.asNodeList, which returnsnullwhen the field is absent:A missing
identifiertakes thenullbranch and reports the subject as populated — the opposite of what the method's own comment says it checks ("Check that we have either .id or .identifier populated"). The check only fires today whenidentifieris written out as a literal[].#46 was about accepting a non-array
identifier, andasNodeListstill does that. Only the null case moves, back to what it did before #46.Change:
identifiers == null ||→identifiers != null &&ididentifier[]EndorsementInspectorbuilds this probe through the one-argument constructor, which defaultsidentifierRequiredto true, so endorsements see the same change.BitstringStatusListCredentialInspectorpasses false and is unaffected, and OB 2.0 does not use this probe.Testing
Added
simple-err-credential-subject-no-id-no-identifier.json, copied from the existing identifier-type fixture withidentifierremoved. There was no fixture for the absent case, which is why the suite did not catch this.Before the fix,
testSimpleJsonCredentialSubjectWithoutIdOrIdentifierfails withdid not find probe id CredentialSubjectProbe; after it, the probe reportsno id in credentialSubject.mvn -pl inspector-vc -am testpasses, 98 tests.