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

experiment: allow Any as output type in nodes #7758

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

psychedelicious
Copy link
Collaborator

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 1 Any output. A switch: 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:

  • Besides Iterate and Collect nodes, which are special cases, hide all nodes with Any outputs.
  • Besides Iterate and Collect nodes, which are special cases, do not allow nodes with Any 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

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

@github-actions github-actions bot added python PRs that change python files invocations PRs that change invocations frontend PRs that change frontend files labels Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend PRs that change frontend files invocations PRs that change invocations python PRs that change python files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant