-
Notifications
You must be signed in to change notification settings - Fork 182
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
Fix empty keys in BlobDataProvider
#3551
Conversation
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 solution works because the empty string is never equal to a locale, because a locale always has a language subtag. It does seem like a fairly narrow change, which is good.
for (locale, idx) in cursor.iter1_copied() { | ||
debug_assert!(idx < self.buffers.len() || locale == Index32U8::SENTINEL); |
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.
Issue: This is problematic because a newer blob won't pass the invariants of an older blob reader
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.
Personally ok with breaking debug assertions for new-blob-old-reader.
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.
We could also instead set the index to 0; it's fine because it'll never be loaded anyway (and if someone does attempt to load it raw, they'll get a deserialize error or potentially GIGO behavior.
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.
The problem is that for a blob with just an empty key, 0
is also invalid as there will be zero buffers.
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'm willing to have debug assertions break in that relatively niche case
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.
(but also I'm not against breaking debug assertions with the =len sentinel in the first place. would prefer to avoid it, really do not care about the empty-blob case)
for (locale, idx) in cursor.iter1_copied() { | ||
debug_assert!(idx < self.buffers.len() || locale == Index32U8::SENTINEL); |
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.
Personally ok with breaking debug assertions for new-blob-old-reader.
for (locale, idx) in cursor.iter1_copied() { | ||
debug_assert!(idx < self.buffers.len() || locale == Index32U8::SENTINEL); |
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.
We could also instead set the index to 0; it's fine because it'll never be loaded anyway (and if someone does attempt to load it raw, they'll get a deserialize error or potentially GIGO behavior.
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.
Ok to use .len()
Fixes #3545