fix(workflows): preserve core_metadata recall fields across workflow roundtrip#9162
Open
Pfannkuchensack wants to merge 1 commit into
Open
Conversation
…roundtrip
The `core_metadata` node is configured with pydantic `extra='allow'` and
carries recall metadata (`loras`, `controlnets`, `ipAdapters`,
`t2iAdapters`, plus model-specific extras like `z_image_seed_variance_*`,
`dype_preset`, `ref_images`). When a generated image's graph was loaded
into the workflow editor and saved, those values were being dropped:
* The four `*MetadataField` collection types were not registered as
StatefulFieldType, so their inputs fell through to
`zStatelessFieldInputInstance`, whose `value` is
`z.undefined().catch(undefined)` — silently coercing the array away.
* Extra keys not declared in the OpenAPI schema were dropped earlier
still, in `graphToWorkflow`, because `template.inputs[key]` was
undefined and the field was skipped with a warning.
Result: the regenerated image had no recall metadata and "Recall all
parameters" reported no LoRA / no variance settings — even though the
backend executed the workflow correctly (`lora_selector` and the
`z_image_seed_variance_enhancer` node were intact via their edges).
This change:
* Registers `LoRAMetadataField`, `ControlNetMetadataField`,
`IPAdapterMetadataField`, `T2IAdapterMetadataField` as stateful field
types with passthrough zod values.
* Adds a synthetic `MetadataExtraField` so undeclared keys on
`extra='allow'` nodes round-trip through the workflow editor.
* `graphToWorkflow` synthesizes an extra-field template for keys not in
the node template, scoped to nodes that accept extras.
* `buildNodesGraph` forwards extra values verbatim when running the
workflow.
* `fieldValidators` and `InputFieldGate` no longer treat undeclared
inputs on extra-accepting nodes as errors / unexpected fields.
Adds regression tests covering the LoRA roundtrip, the extras roundtrip,
and the parseSchema template type for `core_metadata.loras`.
Fixes invoke-ai#9151
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The
core_metadatanode is configured with pydanticextra='allow'and carries recall metadata (loras,controlnets,ipAdapters,t2iAdapters, plus model-specific extras likez_image_seed_variance_*,dype_preset,ref_images). When a generated image's graph was loaded into the workflow editor and saved, those values were being dropped:*MetadataFieldcollection types were not registered asStatefulFieldType, so their inputs fell through tozStatelessFieldInputInstance, whosevalueisz.undefined().catch(undefined)— silently coercing the array away.graphToWorkflow, becausetemplate.inputs[key]was undefined and the field was skipped with a warning.Result: the regenerated image had no recall metadata and "Recall all parameters" reported no LoRA / no variance settings — even though the backend executed the workflow correctly (
lora_selectorand thez_image_seed_variance_enhancernode were intact via their edges).This change:
LoRAMetadataField,ControlNetMetadataField,IPAdapterMetadataField,T2IAdapterMetadataFieldas stateful field types with passthrough zod values.MetadataExtraFieldso undeclared keys onextra='allow'nodes round-trip through the workflow editor.graphToWorkflowsynthesizes an extra-field template for keys not in the node template, scoped to nodes that accept extras.buildNodesGraphforwards extra values verbatim when running the workflow.fieldValidatorsandInputFieldGateno longer treat undeclared inputs on extra-accepting nodes as errors / unexpected fields.Adds regression tests covering the LoRA roundtrip, the extras roundtrip, and the
parseSchematemplate type forcore_metadata.loras.Related Issues / Discussions
Fixes #9151
QA Instructions
Tested end-to-end against a real Invoke instance (v6.12.0, Z-Image Turbo) with a real LoRA. Reproduction steps for reviewers:
strength > 0).lorasarray is present, with the same model and weight as the original.z_image_seed_variance_enabled,z_image_seed_variance_strength,z_image_seed_variance_randomize_percentare present.Automated coverage (added in this PR):
loraMetadataRoundtrip.test.ts—zFieldInputInstancepreserves values for all four*MetadataFieldtypes and acceptsnull.graphToWorkflow.test.ts— full graph → workflow →parseAndMigrateWorkflowroundtrip preserves bothcore_metadata.lorasand undeclared extras (z_image_seed_variance_*).parseSchemaCoreMetadata.test.ts—parseSchemaproduces a statefulLoRAMetadataFieldtemplate forcore_metadata.loras(not a stateless fallback).Run with:
cd invokeai/frontend/web pnpm test:no-watchMerge Plan
Frontend-only change, no migrations and no backend schema impact. Safe to merge whenever; consider including in a patch release alongside other Z-Image bug fixes since the user-visible symptom (LoRA appears to be ignored on workflow re-runs) is a regression hot spot.
Checklist
What's Newcopy (if doing a release after this PR) — defer to release author