Skip to content

Realtime Database After Event Missing values #122

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

Closed
JJ11teen opened this issue Jul 27, 2023 · 4 comments · Fixed by #125
Closed

Realtime Database After Event Missing values #122

JJ11teen opened this issue Jul 27, 2023 · 4 comments · Fixed by #125
Assignees

Comments

@JJ11teen
Copy link

JJ11teen commented Jul 27, 2023

Hello! 👋

There is a bug in the logic to generate the "after" state of a (realtime) database change. The bug appears to be in the below lines of code, only a shallow copy/merge is performed but a deep one is needed.

# Merge delta into data to generate an 'after' view of the data.
if isinstance(before, dict) and isinstance(after, dict):
after = _util.prune_nones({**before, **after})

As an example of a failure case, I had just changed allocation/change from F to G in the following:
image

However I have a listener setup on the root object of the screenshot and the event.data object that is generated by that change was:

Change(
    before={'allocation': {'change': 'F', 'role': 'admin', 'third': 3}, 'details': <redacted>},
    after={'allocation': {'change': 'G'}, 'details': <redacted>})

It should be:

Change(
    before={'allocation': {'change': 'F', 'role': 'admin', 'third': 3}, 'details': <redacted>},
    after={'allocation': {'change': 'G', 'role': 'admin', 'third': 3}, 'details': <redacted>})

Let me know if you need any more info.

Thanks!

@exaby73
Copy link
Contributor

exaby73 commented Aug 1, 2023

Hello @JJ11teen. Unfortunately, I am having some trouble reproducing this issue. Are you able to reproduce this on the Firebase emulator? Could you provide some reproduction code that I may test against?

@exaby73 exaby73 added the waiting for customer response Issue is on hold awaiting more information from OP label Aug 1, 2023
@JJ11teen
Copy link
Author

JJ11teen commented Aug 2, 2023

Hey @exaby73, unfortunately I don't have time to create complete minimal reproducible code for you. Is there any other way I can help you understand the problem I am describing? If you look at the code I have pointed out in db_fn.py it should make sense why the issue is arising without needing to reproduce the problem on your side - The code {**before, **after} is a shallow merge of the before & after dictionaries ("after" at this point is actually the delta). A deep merge is required to accurately construct an "after" state.

For anyone else following along I've worked around this issue in the mean time by (re)querying the current state of the DB to determine the after state.

@exaby73 exaby73 removed the waiting for customer response Issue is on hold awaiting more information from OP label Aug 3, 2023
@JJ11teen
Copy link
Author

JJ11teen commented Aug 5, 2023

Thanks for the fix @exaby73! Do you know roughly when the next release is expected?

@exaby73
Copy link
Contributor

exaby73 commented Aug 6, 2023

Hey @JJ11teen. I couldn't be sure but hopefully soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants