fix(nodes): ensure each invocation overrides _original_model_fields with own field data #8114
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
_original_model_fields
is a dictClassVar
onBaseInvocation
. It stores the original fields for an Invocation, before any modifications are made by the@invocation
decorator.Individual Invocations were intended to override the whole dict, but instead they added their own fields to it.
The dict was therefore accidentally shared amongst all invocation classes. Here's what it looks like for
IPAdapterInvocation
:Note that a ton of fields unrelated to IP Adapter are in there. It shouldn't have those! Here's what it should look like:
Note that it only includes fields from the IP Adapter node.
This bug has a knock-on effect when two invocations share the same field name. The original model field data would be replaced/clobbered.
For example, both
IPAdapterInvocation
andFloatToIntegerInvocation
have amethod
field:We can have this sequence of events:
IPAdapterInvocation
is registered, storing its field data in the dict.cls._original_model_fields["method"]
is set toIPAdapterInvocation.method
's field data.FloatToIntegerInvocation
is registered, storing its field data in the dict.cls._original_model_fields["method"]
is set toFloatToIntegerInvocation.method
's field data.So
IPAdapterInvocation._original_model_fields["method"]
ends up referring toFloatToIntegerInvocation.method
:But it should refer to its own
IPAdapterInvocation.method
, like this:Anything that consumes
_original_model_fields
forIPAdapterInvocation
would get the float node's method field instead of its own.Related Issues / Discussions
n/a
QA Instructions
Run in the debugger to observe
_original_model_fields
. There is no OSS code that consumes it.Merge Plan
n/a
Checklist
What's New
copy (if doing a release after this PR)