Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryptic Error Message When Trying To Expand Local Document #56

Open
LuisOsta opened this issue Jan 11, 2023 · 4 comments
Open

Cryptic Error Message When Trying To Expand Local Document #56

LuisOsta opened this issue Jan 11, 2023 · 4 comments
Assignees

Comments

@LuisOsta
Copy link

LuisOsta commented Jan 11, 2023

TL;DR

I get this error when calling expand in a created document

Error: 0x16d831f98

Details

So I'm trying to expand a JSON-LD document that has no remote URL. This is the code that I have setup to do so:

        let value = serde_json::to_value(credential).unwrap().to_string();

        println!("{value}");

        // Create a "remote" document by parsing a file manually.
        let input = json_ld::RemoteDocument::new(
            // We use `IriBuf` as IRI type.
            None,
            // Optional content type.
            None,
            // Parse the file.
            json_ld::syntax::Value::parse_str(
                value.as_str(),
                |span| span, // keep the source `Span` of each element as metadata.
            )
            .expect("Error creating remote document"),
        );

        // Use `NoLoader` as we won't need to load any remote document.
        let mut loader = json_ld::NoLoader::<_, _>::new();

        // Expand the "remote" document.
        let expanded = aw!(input.expand(&mut loader));

        match expanded {
            Err(e) => {
                println!("Error: {:?}", e);
            }
            Ok(expanded) => {
                for object in expanded.into_value() {
                    if let Some(id) = object.id() {
                        let name = object
                            .as_node()
                            .unwrap()
                            .get_any(&iri!("http://xmlns.com/foaf/0.1/name"))
                            .unwrap()
                            .as_str()
                            .unwrap();

                        println!("id: {id}");
                        println!("name: {name}");
                    }
                }
            }
        }

The value printed by the print statement is

{
   "@context":[
      "https://www.w3.org/2018/credentials/v1",
      "https://w3id.org/traceability/v1"
   ],
   "credentialSubject":{
      "BIC11":"TDOMCATTTOR",
      "accountId":"1111111",
      "address":{
         "addressCountry":"Canada",
         "addressLocality":"Toronto",
         "addressRegion":"ON",
         "postalCode":"M3B 1A2",
         "streetAddress":"19 Knox St",
         "type":[
            "PostalAddress"
         ]
      },
      "familyName":"Smith",
      "givenName":"Alice",
      "iban":"GB74GSLD04296280001319",
      "id":"did:knox:z6Mk2cd21e9abe57fae7...31073da1b522790e63834fe17a4c2be",
      "routingInfo":{
         "code":"GBDSC",
         "type":[
            "RoutingInfo"
         ],
         "value":"042962"
      },
      "type":[
         "BankAccount"
      ]
   },
   "id":"12345",
   "issuanceDate":"2023-01-11T23:33:55.316962+00:00",
   "issuer":"did:test:z6MkncBtsFLzCQBzVFNAFkwbrerB4tGnX76S3hZKgd6ytz92",
   "type":[
      "VerifiableCredential",
      "BankAccountCredential"
   ]
}

This JSON-LD document is processed perfectly fine by the JSON-LD playground but results in the following error when using this library:

Error: 0x16d831f98
@LuisOsta
Copy link
Author

LuisOsta commented Jan 11, 2023

In case you wanted to see the whole thing in context you can check out this PR - knox-networks/ssi#111. The test that results in this error is test_context_adherance in the lib.rs tests

@timothee-haudebourg
Copy link
Owner

That's weird. I'll take a look.

@LuisOsta
Copy link
Author

@timothee-haudebourg Did you end up finding anything out?

@timothee-haudebourg
Copy link
Owner

I can't reproduce the error. I can expand the document into

[
  {
    "@id": "12345",
    "@type": [
      "https://www.w3.org/2018/credentials#VerifiableCredential",
      "https://w3id.org/traceability#BankAccountCredential"
    ],
    "https://www.w3.org/2018/credentials#credentialSubject": [
      {
        "@id": "did:knox:z6Mk2cd21e9abe57fae7...31073da1b522790e63834fe17a4c2be",
        "@type": [
          "https://w3id.org/traceability#BankAccount"
        ],
        "https://w3id.org/traceability#BIC11": [
          {
            "@value": "TDOMCATTTOR"
          }
        ],
        "https://w3id.org/traceability#accountId": [
          {
            "@value": "1111111"
          }
        ],
        "https://schema.org/PostalAddress": [
          {
            "@type": [
              "https://schema.org/PostalAddress"
            ],
            "https://schema.org/addressCountry": [
              {
                "@value": "Canada"
              }
            ],
            "https://schema.org/addressLocality": [
              {
                "@value": "Toronto"
              }
            ],
            "https://schema.org/addressRegion": [
              {
                "@value": "ON"
              }
            ],
            "https://schema.org/postalCode": [
              {
                "@value": "M3B 1A2"
              }
            ],
            "https://schema.org/streetAddress": [
              {
                "@value": "19 Knox St"
              }
            ]
          }
        ],
        "http://schema.org/familyName": [
          {
            "@value": "Smith"
          }
        ],
        "http://schema.org/givenName": [
          {
            "@value": "Alice"
          }
        ],
        "https://w3id.org/traceability#iban": [
          {
            "@value": "GB74GSLD04296280001319"
          }
        ],
        "https://w3id.org/traceability#routingInfo": [
          {
            "@type": [
              "https://w3id.org/traceability#RoutingInfo"
            ],
            "https://w3id.org/traceability#routingInfoCode": [
              {
                "@value": "GBDSC"
              }
            ],
            "https://w3id.org/traceability#routingInfoValue": [
              {
                "@value": "042962"
              }
            ]
          }
        ]
      }
    ],
    "https://www.w3.org/2018/credentials#issuanceDate": [
      {
        "@value": "2023-01-11T23:33:55.316962+00:00",
        "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
      }
    ],
    "https://www.w3.org/2018/credentials#issuer": [
      {
        "@id": "did:test:z6MkncBtsFLzCQBzVFNAFkwbrerB4tGnX76S3hZKgd6ytz92"
      }
    ]
  }
]

I this still an issue?

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

No branches or pull requests

2 participants