-
Notifications
You must be signed in to change notification settings - Fork 97
Skip keyless update entries in updateSnapshots instead of crashing #818
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
base: main
Are you sure you want to change the base?
Changes from all commits
ebca04f
81627b0
19dade9
758d11f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1210,7 +1210,15 @@ function updateSnapshots<TKey extends OnyxKey>(data: Array<OnyxUpdate<TKey>>, me | |
|
|
||
| let updatedData: Record<string, unknown> = {}; | ||
|
|
||
| for (const {key, value} of data) { | ||
| for (const {key, value, onyxMethod} of data) { | ||
| if (typeof key !== 'string') { | ||
| // clear/multiset entries legitimately carry no key; snapshots have nothing to update for them | ||
| if (onyxMethod !== METHOD.CLEAR && onyxMethod !== METHOD.MULTI_SET) { | ||
| Logger.logInfo(`Invalid ${typeof key} key (method: ${onyxMethod}, key: ${String(key).slice(0, 50)}) provided in Onyx update. Skipping snapshot update for this entry.`); | ||
| } | ||
| continue; | ||
|
Comment on lines
+1214
to
+1219
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, add Log message, same as it's done in Onyx.update
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done
Comment on lines
+1215
to
+1219
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, so this is not a regression with this code, so we could choose to handle it in a follow-up. What we have here is strictly better than what we have on main, which errors in this case. That said, we probably should update |
||
| } | ||
|
|
||
| // snapshots are normal keys so we want to skip update if they are written to Onyx | ||
| if (OnyxKeys.isCollectionMemberKey(snapshotCollectionKey, key)) { | ||
| continue; | ||
|
|
||
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.