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

non unique dictionary key error #191

Closed
colek42 opened this issue Oct 28, 2022 · 9 comments
Closed

non unique dictionary key error #191

colek42 opened this issue Oct 28, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@colek42
Copy link
Member

colek42 commented Oct 28, 2022

General information:

main
linux
1.19.1

failed to create link metadata: left stripping has resulted in non unique dictionary key: /node_modules/@actions/tool-cache/node_modules/uuid/bin/uuid

When testing the in-toto run action we run into the above error when calculating the materials for the job.

@colek42 colek42 added the bug Something isn't working label Oct 28, 2022
@adityasaky
Copy link
Member

Interesting. This error is triggered by a check that kicks in when applying left-strip patterns to see if a left strip results in a collision in artifact paths. Specifically here, it seems to be /node_modules/@actions/tool-cache/node_modules/uuid/bin/uuid. I'm not sure why you're running into something at that path twice given the materials and products you're trying to record though. I wonder if it's the runDir causing problems.

@adityasaky
Copy link
Member

Let me experiment with it a bit.

@adityasaky
Copy link
Member

Also, you've excluded node_modules but looks like that didn't take.

@adityasaky
Copy link
Member

Okay, so I don't yet have an answer for why the exclude didn't work but the issue was https://github.com/testifysec/intoto-run-action/blob/main/node_modules/%40actions/tool-cache/node_modules/.bin/uuid. There was a symlink pointing to an artifact that was already recorded. We should clear up the error message to indicate it can happen even in non left strip situations. cc @shibumi

@adityasaky
Copy link
Member

adityasaky commented Oct 28, 2022

So -e / --exclude works with a trailing slash. The python impl doesn't require that slash, we should ticketize this separately. For now, adding the trailing slash should solve the issue entirely since the symlinks won't be encountered.

TODO:

  1. Ticket for required trailing slash in -golang's exclude pattern
  2. Symlinks should record the hash of the target but the artifact path should be of the link, not the target

@colek42
Copy link
Member Author

colek42 commented Oct 28, 2022

Okay, so I don't yet have an answer for why the exclude didn't work but the issue was https://github.com/testifysec/intoto-run-action/blob/main/node_modules/%40actions/tool-cache/node_modules/.bin/uuid. There was a symlink pointing to an artifact that was already recorded. We should clear up the error message to indicate it can happen even in non left strip situations. cc @shibumi

Should we change this from an error to a warning and continue?

@adityasaky
Copy link
Member

I think the problem is that with symlink management, the destination path is used. The file at the destination should be hashed but the path should be the path to the symlink itself.

foo
bar -> foo

When recording both, the paths should be foo and bar with both entries recording the same hash. This is how the python implementation behaves too. This would avoid the left-strip error condition from occurring.

As for warning vs error in the general sense, I think not. With left strips, we can have collisions with entirely different files, where only one will be recorded. The short term resolution for this issue is to exclude node_modules with a trailing slash. Long term, we should consolidate exclude pattern handling and fix the path recorded for symlinks.

@adityasaky
Copy link
Member

I believe the exclude patterns issue might belong in @shibumi's go-pathspec.

@adityasaky
Copy link
Member

I'm closing this because of the updated symlink handling in #194. @shibumi I'd appreciate your thoughts on the pathspec bits but that can be handled separately!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants