-
Notifications
You must be signed in to change notification settings - Fork 1
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
LRS-72 Handle deduplicated attachment multiparts #81
Conversation
src/test/com/yetanalytics/lrs/pedestal/interceptor/xapi/statements/attachment_test.cljc
Outdated
Show resolved
Hide resolved
(let [sha (get headers "X-Experience-API-Hash")] | ||
(if-let [extant (get m sha)] | ||
m | ||
(assoc m sha multipart)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that attachments with different data will have different SHAs, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, even if it isn't mathematically true 🙈 . Unfortunately there isn't a stable way to tie an attachment to a specific referencing object in a statement batch really, so there isn't much to be done about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case you may want to add that to the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the remote, theoretical possibility of a hash collision is outside the scope of the docs. At any rate, the docs link to this PR 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh so hash collisions aren't that common with SHAs? From our past convos I got the impression that the SHA2 algorithm was busted and that collisions were the order of the day. 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's like SHA-256 it's quite unlikely. I'm actually a little confused about the spec language here, it only says that:
A Learning Record Provider SHOULD use SHA-256, SHA-384, or SHA-512 to populate the "sha2" property.
And of course doesn't require the LRS to validate it, because how would it know the alg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, yes we like to assume that impossible things will happen, it's just that in this instance the spec limits us.
LRS-72
Currently lrs expects attachment requests to contain one attachment part for every attachment reference in statement data. The spec language is ambiguous in this regard: https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Communication.md#requirements-for-attachment-statement-batches
It does however say that LRPs should normalize/deduplicate attachments being sent, so LRS (and its impls) should handle this.
Example with multiple references + deduplicated attachments that currently fails on our system:
failing example
Example with multiple references and duplicated attachments that succeeds:
passing example
Additionally, passing to the impl is an open question:
In its current state this PR takes option 2, but that's up for discussion!