experiment: allow Any as output type in nodes #7758
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Allow
Any
to be an output type for node fields. This introduces a major footgun, so we haven't enabled it.It's safe for nodes to have
Any
type inputs, because that node knows up front that it could get literally anything as an input. The node knows it must handle literally anything and it is able to take that responsibility.It is unsafe for nodes to have
Any
type outputs, because then every node must be able to handle literally anything as an input. It shifts the responsibility of dealing with untyped inputs to every node, instead of only the nodes that explicitly accept them.This also encourages node authors to just slap
Any
on every output because that's way easier than actually defining types.Ok, all that said, this does increase node power. For example, we can provide a flexible Switcher node (included in this PR). This node has 2
Any
inputs and 1Any
output. Aswitch: bool
input lets you choose between the two inputs.If we want to accept the change in this PR, we could add a setting the workflow editor to make this opt-in:
Iterate
andCollect
nodes, which are special cases, hide all nodes withAny
outputs.Iterate
andCollect
nodes, which are special cases, do not allow nodes withAny
outputs to pass validation.Another way to reduce footguns would be to special-case nodes like the Switcher, making the
Any
type function more like a generic. The type would be inferred from one of the inputs, and its output would be treated as the inferred type. Obviously this reduces the flexibility of the node.I think I'm OK with this change if it is opt-in.
Related Issues / Discussions
https://discord.com/channels/1020123559063990373/1278825261432967169/1347633191816527985
QA Instructions
Try the switcher node out.
Merge Plan
n/a
Checklist
What's New
copy (if doing a release after this PR)