Skip to content
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

Proper serialization for chained Event payloads #1725

Merged
merged 6 commits into from
Aug 31, 2023

Conversation

masenf
Copy link
Collaborator

@masenf masenf commented Aug 31, 2023

Calling an EventHandler returns an EventSpec with the function call arguments encoded as Var.

This works fine when formatting the Var into an event via format.format_event, however when directly creating a payload and serializing the entire Event to send to the client to be queued, the fix_events function was just taking the "name" of the Var, which is a json-encoded value.

In order to properly serialize the event payload, these Var args need to be decoded back into their python values, so that the payload as a whole can be re-serialized properly.

Implement a Var._decode operation, which operates (mostly) as the inverse of Var.create. This is an underscore method, because it actually doesn't return another Var, but instead the real python value that the Var is created from.

Fix #1722


Add/update unit and integration test cases in this area.

masenf added 6 commits August 31, 2023 02:35
Ensure that fix_events converts the arg types correctly
ensure the value is a real python boolean
Calling an EventHandler returns an EventSpec with the function call arguments
encoded as `Var`. This works fine when formatting the Var into an event via
`format.format_event`, however when directly creating a payload and serializing
the entire Event to send to the client to be queued, the `fix_events` function
was just taking the "name" of the var, which is a json-encoded value. In order
to properly serialize the event payload, these Var args need to be decoded back
into their python values, so that the payload as a whole can be re-serialized.

Implement a `Var._decode` operation, which operates (mostly) as the inverse of
`Var.create`. This is an underscore method, because it actually doesn't return
another Var, but instead the real python value that the Var is created from.

Fix #1722
Yikes, these tests had codified the bad serialization in their expectations;
now that we serialize correctly, update the tests.
Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice fix!

@picklelo picklelo merged commit cc89f2b into main Aug 31, 2023
34 checks passed
@masenf masenf deleted the masenf/bogus-serialization branch September 7, 2023 22:35
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 this pull request may close these issues.

State variable becomes string when passed as argument to another State Event
2 participants