dc4eu / vc

European Wallet
BSD 2-Clause "Simplified" License
7 stars 9 forks source link

Not possible to upload documents with same authentic_source and document_id but different document_type #78

Open JuAlMan opened 3 months ago

JuAlMan commented 3 months ago

Using image docker.sunet.se/dc4eu/apigw:apiv28

I uploaded a document with the following meta object:

"meta": {
    "authentic_source": "DE:DRV21001",
    "collect": {

    },
    "credential_valid_from": 0,
    "credential_valid_to": 0,
    "document_id": "12345",
    "document_type": "PDA1",
    "document_version": "1.0.0",
    "real_data": true
  }

Then i uploaded a second document by changing the document_type to "EHIC". Querying the document with Type PDA1 works just fine but when i try to query with type EHIC i get an error message that no documents could be found. This is the request i used for queriying the EHIC document:

{
  "authentic_source": "DE:DRV21001",
  "document_id": "12345",
  "document_type": "EHIC"
}

As a document is identified by document_id, authentic_source and document_type it should be possible to upload documents with same id but different type.

masv3971 commented 2 months ago

It's because the save call to the database goes via a async call. Will change that behavior.

JuAlMan commented 2 months ago

I tried:

"authentic_source": "DE:DRV70001",
"document_id": "123",
"document_type": "PDA1"

And then:

"authentic_source": "DE:DRV70001",
"document_id": "123",
"document_type": "EHIC"

It still doesn't seem to work, I get the following error: "document_already_exists".

masv3971 commented 2 months ago

Should be solved with, c706009186044bbae8851ab730455c16e18f9394

Please try the latest apiv28 docker tag.

JuAlMan commented 1 month ago

I still get a duplicate key error. In the logs of the apigw container i get the following message:

Failed to save document {"error": "write exception: write errors: [E11000 duplicate key error collection: vc.datastore index: document_id_uniq dup key: { : \"12345\", : \"DE:DRV70001\" }]"}

It seems the document_type isn't respected as part of the unique key.

I used the 0.4.1 image tag now, but also tried with apiv28 and got the same error