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

remote agents returns VCs three times #1285

Closed
cre8 opened this issue Oct 26, 2023 · 2 comments · Fixed by #1299
Closed

remote agents returns VCs three times #1285

cre8 opened this issue Oct 26, 2023 · 2 comments · Fixed by #1299
Labels
bug Something isn't working triage

Comments

@cre8
Copy link
Contributor

cre8 commented Oct 26, 2023

Bug severity
5

Describe the bug
When using the remote agent plugin, each VC is included three times in the http response:

image

image

To Reproduce
Steps to reproduce the behaviour:
1 include the remote and client plugin
2 write a credential to the database
3 request it via the remote client

When I fetch the credentials directly in the backend code, I get two credentials back. So the problem is not in the dataStoreORMGetVerifiableCredentials, but in the usage when used via the remote call.

Observed behaviour
Results do not match. I haven't checked if other functions behave the same or if it's only the dataStoreORMGetVerifiableCredentials call.

Expected behaviour
That the remote call returns the same result as the "normal" call.

Details
If applicable, add screenshots, error messages or stack traces to help explain your problem.

Additional context
Add any other context about the problem here.

Versions (please complete the following information):

  • Veramo: 5.x
@cre8 cre8 added the bug Something isn't working label Oct 26, 2023
@mirceanis
Copy link
Member

mirceanis commented Dec 7, 2023

The method you are using based on the screenshot seems to be dataStoreORMGetVerifiableCredentialsByClaims (I know, we probably could pick a better name).
But what happens is that when a credential is stored, an entry is also added to the claims table for each property of the credentialSubject. Then, if multiple claims from a credential are matching (like when you aren't adding any conditions to the query), you get a credential result for each match, which happens to be the same credential.

This is indeed a bug, as the method name suggests that credentials are returned, so they should be unique.

The fix should be simple as the credentials can be grouped by hash here: https://github.com/decentralized-identity/veramo/blob/462735d138bc4984c0fcf3f72ca7d49e3187ceb7/packages/data-store/src/data-store-orm.ts#L205C36-L205C36

I think the bug doesn't appear in @veramo/data-store-json as credentials from the claim query are first added to a Set before being mapped to the result.

Do you have bandwidth to propose a PR with a fix?


Also, what tool are you using to look at the database? perhaps we can suggest it as a debugging tool in our docs

@cre8
Copy link
Contributor Author

cre8 commented Dec 8, 2023

I think I can assign the issue to myself.

I used an extension for vscode called sqltools

mirceanis pushed a commit that referenced this issue Dec 8, 2023
…ableCredentialsByClaims` (#1299)

fixes #1285

Co-authored-by: Mirko Mollik <mirko.mollik@fit.fraunhofer.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants