-
Notifications
You must be signed in to change notification settings - Fork 40
Improve workflow/steps input/outputs serializer #175
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?
Conversation
| if inputStr, ok := workflow.Input.(string); ok { | ||
| if strings.Contains(inputStr, "Failed to decode") { | ||
| ctx.logger.Warn("Skipping workflow recovery due to input decoding failure", "workflow_id", workflow.ID, "name", workflow.Name) | ||
| 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.
Unused
f9c14ce to
c609278
Compare
cd0b4be to
c48821f
Compare
…al registration for gob interface
kraftp
left a comment
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 probably missing it, but where in this PR enforces what can and can't be serialized?
There is actually no way to declare a generic type that exclude all interfaces or nested pointers. We'd have to do it at runtime, both in But doing it for interfaces would also prevent users from registering themselves the interface. Manual registration from the user makes the whole thing work. I think we should just clearly document it. Do you think we should error / panic at runtime if we identify nested pointers? |
It's fine if there's no compile-time way to identify unserializable types. There isn't any in the other languages either. But we should clearly document what can and can't be serialized (ideally supplemented with links to gob docs) and should throw clear errors if we get something that isn't serializable. |
Added the detection / prevention of nested pointers in eb4371a |
kraftp
left a comment
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.
Just to be clear, what's wrong with nested pointers?
On the type gobValue struct {
value any
}Doing so allows Gob to decode anything into an On the typed paths (e.g., |
I don't get it--why is this PR so complex and why is there so much special-casing? We've had no serialization issues in the other three languages. Is Go just really bad for this, or are we doing something wrong or overcomplicating the problem or trying to do too much? |
It all boils down to how one can decode a value (json or gob) into a variable and to the fact there are no heterogeneous generic collections in Go. If you decode directly into the target type, the decoder implementation should know how to reconstruct the target type properly. If you don't, i.e., you decode into When you want to return a list of workflows/steps, you can't gather them in a slice where the type is known. The only way out I can think out of this requires:
if t, ok := types[name]; ok {
return reflect.New(t).Interface(), true
}
JSON as roughly the same issues This is a limitation of the language. For example the Temporal go sdk does not even have a list workflowS (plural) method, and its "list workflow" method doesn't even return workflow inputs/outputs directly. edit: we could also decide to disable loading inputs/outputs in the list methods, but that would make the client sides more difficult. |
This PR:
What we do not support:
gob.Registerthe concrete implementation of the interface)Tests