Skip to content

Instantly share code, notes, and snippets.

@chrisDeFouRire
Last active September 1, 2023 12:08
Show Gist options
  • Save chrisDeFouRire/ebdd4eec2c763215e0ace0a268b431a5 to your computer and use it in GitHub Desktop.
Save chrisDeFouRire/ebdd4eec2c763215e0ace0a268b431a5 to your computer and use it in GitHub Desktop.
PoluygonID: Cannot parse claim debugging session

Adding some logging

I've added more logging around claim.go:170: coreClaim, err := schemaPkg.Process(ctx, c.loaderFactory(req.Schema), credentialType, vc, opts)

time=2023-09-01T03:59:23.476Z level=INFO msg=c.loaderFactory(req.Schema) !BADKEY="&{URL:https://ipfs.io CID:QmTkShmtAVtbkTvZV8HDEmpfG3KHPoLHkLPvH3upuSk9Kg}"
time=2023-09-01T03:59:23.476Z level=INFO msg=credentialType !BADKEY=urn:uuid:327bcc66-2a0c-41ca-9602-4beb19becaed
time=2023-09-01T03:59:23.476Z level=INFO msg=vc !BADKEY="{ID:http://localhost:3002/v1/credentials/ef770b97-487b-11ee-b401-5254b9bd8ca1 Context:[https://www.w3.org/2018/credentials/v1 https://schema.iden3.io/core/jsonld/iden3proofs.jsonld ipfs://QmWDHqomUmFYLTwqdVdMueUpGJgz4ttJhoALnHj4XKqjJo] Type:[VerifiableCredential country] Expiration:<nil> IssuanceDate:2023-09-01 03:59:23.080949411 +0000 UTC m=+13.832647952 CredentialSubject:map[country:TH id:did:polygonid:polygon:mumbai:2qNpRLUS1wXAsXxpQtcW6QFQdkP6KMDjWWvvryaXpe type:country] CredentialStatus:0xc000554ba0 Issuer:did:polygonid:polygon:mumbai:2qNpRLUS1wXAsXxpQtcW6QFQdkP6KMDjWWvvryaXpe CredentialSchema:{ID:ipfs://QmTkShmtAVtbkTvZV8HDEmpfG3KHPoLHkLPvH3upuSk9Kg Type:JsonSchema2023} Proof:[]}"
time=2023-09-01T03:59:23.476Z level=ERROR msg="credential subject attributes don't match the provided schema" err="error parsing claim"
time=2023-09-01T03:59:23.476Z level=ERROR msg="error parsing claim" err="error parsing claim"

For memory, this is the schema I'm using: https://schema-builder.polygonid.me/schemas/83938bc0-d1f2-49d1-b09f-abfcb85a0c4f

And I'm using "TH" as the country.

I've noted that

CredentialSubject:map[country:TH id:did:polygonid:polygon:mumbai:2qNpRLUS1wXAsXxpQtcW6QFQdkP6KMDjWWvvryaXpe type:country]

contains a "type:country" attribute that I wasn't expecting because it's not in the schema (which contains only "id" and "country" attributes. I don't know if it's significant.

More logging

Adding some logging around schema.go:117: claim, err := pr.ParseClaim(ctx, credential, credentialType, schema, options) logs the following:

time=2023-09-01T04:16:41.080Z level=INFO msg=credential !BADKEY="{ID:http://localhost:3002/v1/credentials/59d617a9-487e-11ee-9f81-5254b9bd8ca1 Context:[https://www.w3.org/2018/credentials/v1 https://schema.iden3.io/core/jsonld/iden3proofs.jsonld ipfs://QmWDHqomUmFYLTwqdVdMueUpGJgz4ttJhoALnHj4XKqjJo] Type:[VerifiableCredential country] Expiration:<nil> IssuanceDate:2023-09-01 04:16:40.535473811 +0000 UTC m=+14.891850703 CredentialSubject:map[country:TH id:did:polygonid:polygon:mumbai:2qNpRLUS1wXAsXxpQtcW6QFQdkP6KMDjWWvvryaXpe type:country] CredentialStatus:0xc00062baa0 Issuer:did:polygonid:polygon:mumbai:2qNpRLUS1wXAsXxpQtcW6QFQdkP6KMDjWWvvryaXpe CredentialSchema:{ID:ipfs://QmTkShmtAVtbkTvZV8HDEmpfG3KHPoLHkLPvH3upuSk9Kg Type:JsonSchema2023} Proof:[]}"
time=2023-09-01T04:16:41.081Z level=INFO msg=credentialType !BADKEY=urn:uuid:327bcc66-2a0c-41ca-9602-4beb19becaed
time=2023-09-01T04:16:41.081Z level=INFO msg=schema !BADKEY="{\"$metadata\":{\"uris\":{\"jsonLdContext\":\"ipfs://QmWDHqomUmFYLTwqdVdMueUpGJgz4ttJhoALnHj4XKqjJo\"},\"type\":\"country\",\"version\":\"v1\"},\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"description\":\"Country\",\"title\":\"Country\",\"properties\":{\"credentialSubject\":{\"description\":\"Stores the data of the credential\",\"title\":\"Credential subject\",\"properties\":{\"country\":{\"description\":\"country\",\"title\":\"country\",\"type\":\"string\"},\"id\":{\"description\":\"Stores the DID of the subject that owns the credential\",\"title\":\"Credential subject ID\",\"format\":\"uri\",\"type\":\"string\"}},\"required\":[\"country\"],\"type\":\"object\"},\"@context\":{\"type\":[\"string\",\"array\",\"object\"]},\"expirationDate\":{\"format\":\"date-time\",\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"issuanceDate\":{\"format\":\"date-time\",\"type\":\"string\"},\"issuer\":{\"type\":[\"string\",\"object\"],\"format\":\"uri\",\"properties\":{\"id\":{\"format\":\"uri\",\"type\":\"string\"}},\"required\":[\"id\"]},\"type\":{\"type\":[\"string\",\"array\"],\"items\":{\"type\":\"string\"}},\"credentialSchema\":{\"properties\":{\"id\":{\"format\":\"uri\",\"type\":\"string\"},\"type\":{\"type\":\"string\"}},\"required\":[\"id\",\"type\"],\"type\":\"object\"}},\"required\":[\"credentialSubject\",\"@context\",\"id\",\"issuanceDate\",\"issuer\",\"type\",\"credentialSchema\"],\"type\":\"object\"}"
time=2023-09-01T04:27:25.242Z level=INFO msg=err !BADKEY="protected term redefinition: invalid JSON-LD syntax; tried to redefine a protected term"

So the error is actually protected term redefinition: invalid JSON-LD syntax; tried to redefine a protected term and it's hidden behind a generic "can't parse claim".

I don't know where to go from there.

Going deeper

It appears that the parseClaim function returns this error:

time=2023-09-01T12:05:33.995Z level=INFO msg="claim parsing error" err="multiple parents found"

I'll submit a pull request to log this error instead of just wrapping it in a "cannot parse claim" error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment