hyperledger / anoncreds-rs

anoncreds-rs
https://wiki.hyperledger.org/display/anoncreds
Apache License 2.0
73 stars 51 forks source link

Getting an error when try to create Schema via NodeJS Wrapper #334

Closed maximlamanovskiy closed 2 months ago

maximlamanovskiy commented 2 months ago

Hi!

I try to create Schema via NodeJS wrapper and getting this error: AnoncredsError: Input error [missing fieldschema_idat line 1 column 3507]. I'm using create method from Schema.ts. Also I've tried to use fromJson and pass schema_id into it somehow, but still no results. I've tried to change version, use 0.2.0, 0.2.1 and 0.2.2 - still getting the same error. I've tried to manually build the lib and put it into native dir, still the same error. Try to change python version, node version, pnpm version, use npm instead of pnpm. But it doesn't help. Try to run on other OS - Mint, MacOS, Debian 12 (Docker), Ubuntu (WSL2). But it was working one week ago. I'm using:

Here is a full stack-trace:

AnoncredsError: Input error [missing field `schema_id` at line 1 column 3507]
    at NodeJSAnoncreds.handleError (/home/redmarsel/Work/navozyme/identity-verification-proxy/node_modules/.pnpm/@hyperledger+anoncreds-nodejs@0.2.2/node_modules/@hyperledger/anoncreds-nodejs/src/NodeJSAnoncreds.ts:54:11)
    at NodeJSAnoncreds.createSchema (/home/redmarsel/Work/navozyme/identity-verification-proxy/node_modules/.pnpm/@hyperledger+anoncreds-nodejs@0.2.2/node_modules/@hyperledger/anoncreds-nodejs/src/NodeJSAnoncreds.ts:80:10)
    at Function.create (/home/redmarsel/Work/navozyme/identity-verification-proxy/node_modules/.pnpm/@hyperledger+anoncreds-shared@0.2.2/node_modules/@hyperledger/anoncreds-shared/src/api/Schema.ts:15:33)
    at indyVdrVerifyCredential (/home/redmarsel/Work/navozyme/identity-verification-proxy/src/service/IndyVdrService.ts:63:25)
    at verifyCredential (/home/redmarsel/Work/navozyme/identity-verification-proxy/src/main/Credential.ts:42:38)
    at async main (/home/redmarsel/Work/navozyme/identity-verification-proxy/src/demo.ts:17:21) {
  code: 1,
  extra: undefined
}
berendsliedrecht commented 2 months ago

Can you provide a reproducible snippet?

maximlamanovskiy commented 2 months ago

Alright, I've found a problem. I was passing incorrcet data into Credential.fromJson, instead of such object: {"schema_id":"8QkAFnjQQzm7LXZ297pzmK:2:test-schema:1.0.0", ...}, I was passing something like this: {"credential":{"schema_id":"8QkAFnjQQzm7LXZ297pzmK:2:test-schema:1.0.0", ...}}. But it's really strange, that stack trace points me on Schema.create method instead of Credential.fromJson, I've spent two days on finding the problem with creating schema 😅