Skip to content

Converter hints #296

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Converter hints #296

wants to merge 2 commits into from

Conversation

cretz
Copy link
Member

@cretz cretz commented Jul 8, 2025

What was changed

A concept of "converter hint" has been added. In most user-facing places where an object may get serialized or deserialized, a converter hint can be provided to help custom converters get contextual information about what to do. The default converters do nothing with this today, but custom converters can use these as "type hints" to know things like what type to deserialize into.

While this PR is significant, it should only affect those that choose to use the feature.

💥 BACKWARDS INCOMPAT - There are technically backwards incompatible changes to the signature of converters for those with custom converters today. This is considered an acceptable tradeoff for those rare cases pre-GA.

Checklist

  1. Closes [Feature Request] Support "hints" for payload conversion #271

@cretz cretz requested a review from a team as a code owner July 8, 2025 14:55
@cretz cretz force-pushed the converter-hints branch from 200c1a0 to 25214a4 Compare July 8, 2025 14:57
@Sushisource
Copy link
Member

Not to blow up your whole thing here, but... did you consider having a class like RawPayload but instead ObjectWithHint or something, that could be used as a wrapper around the user's input/return value/whatever so that we don't have to have these hints as extra parameters to so many APIs?

@cretz
Copy link
Member Author

cretz commented Jul 8, 2025

Not to blow up your whole thing here, but... did you consider having a class like RawPayload but instead ObjectWithHint or something

This doesn't help deserialization, because you need to know what type you want to deserialize into before the deserialization happens. So you have to provide that hint somewhere. Ruby simply has no concept of type hinting where we can determine what type you intend.

that could be used as a wrapper around the user's input/return value/whatever so that we don't have to have these hints as extra parameters to so many APIs?

Sure, users can still use wrappers like that with their converters if they want. But we would like to be like other SDKs and let the definitions of the things (e.g. activities, workflows, signals, queries, updates, nexus operations, etc) apply the hints, not the caller. All the other hint parameters are as overrides or for when you don't have the definition present.

So for a workflow for instance, users using this feature will set workflow_arg_hint and workflow_result_hint on their workflow and that's it. Now callers get it (client and child workflow) and implementers get it (deserialization of args, serialization of result). This matches behavior by other SDKs. We tried to make it generic enough that it's effectively just "converter metadata at declaration time".

Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

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

Yeah, that makes sense. Just a bit depressing how much surface area this affects, but, I don't have any reasonable ideas on how to solve that.

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.

[Feature Request] Support "hints" for payload conversion
2 participants