Server: Fixes #10118: Missing record validation before trying to add item to user #10471
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #10118
The error:
While I could not reproduce the error, I think it is safe to assume that it could happen during the
ItemModel.processOrphanedItems
.Basically what would happen is that a item would be orphaned, the
processOrphanedItems
would start and while it was happening the file was deleted before the process had time added the item back to the user collection.That means that when
UserItemModel.add
happened, it would not found a item record anymore, which end up causing the error inside theUserItemModel.addMulti
.Testing
At first, I tried to add a more complex test that emulated the behavior, but it was getting very complicated and taking a lot of time, If the reviewer's opinion is different I can try to reproduce the behavior, but the simple test I added already will cover the potential regression if someone removes one of the checks.