invoke-ai/InvokeAI · error · BatchDuplicateNodeFieldError

Each batch data must have unique node_id and field_name

Error message

Each batch data must have unique node_id and field_name

What it means

Each batch datum targets one (node_path, field_name) pair; duplicate pairs would make the batch expansion ambiguous. The BatchDuplicateNodeFieldError is raised by validate_unique_field_mappings when the same node field appears more than once in the batch data.

Source

Thrown at invokeai/app/services/session_queue/session_queue_common.py:135

                    continue

                # Get the type of the first item in the list
                first_item_type = type(datum.items[0])
                for item in datum.items:
                    if type(item) is not first_item_type:
                        raise BatchItemsTypeError("All items in a batch must have the same type")
        return v

    @field_validator("data")
    def validate_unique_field_mappings(cls, v: Optional[BatchDataCollection]):
        if v is None:
            return v
        paths: set[tuple[str, str]] = set()
        for batch_data_list in v:
            for datum in batch_data_list:
                pair = (datum.node_path, datum.field_name)
                if pair in paths:
                    raise BatchDuplicateNodeFieldError("Each batch data must have unique node_id and field_name")
                paths.add(pair)
        return v

    @model_validator(mode="after")
    def validate_batch_nodes_and_edges(self):
        if self.data is None:
            return self
        for batch_data_list in self.data:
            for batch_data in batch_data_list:
                try:
                    node = self.graph.get_node(batch_data.node_path)
                except NodeNotFoundError:
                    raise NodeNotFoundError(f"Node {batch_data.node_path} not found in graph")
                if batch_data.field_name not in type(node).model_fields:
                    raise NodeNotFoundError(f"Field {batch_data.field_name} not found in node {batch_data.node_path}")
        return self

    @field_validator("graph")

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Remove the duplicate batch data entry, keeping one per (node_path, field_name) pair
  2. Deduplicate with paths = set((d.node_path, d.field_name) for ...) in code that builds batch data
  3. If two collections must feed the same field, merge their items into one collection instead
  4. Review hand-edited batch JSON for duplicated keys

Example fix

// before
{"data": [[{node_path: "n", field_name: "prompt", ...}], [{node_path: "n", field_name: "prompt", ...}]]}
// after: merge into one datum
{"data": [[{node_path: "n", field_name: "prompt", items: [...all items...]}]]}
Defensive patterns

Strategy: validation

Validate before calling

def validate_unique_pairs(data):
    seen = set()
    for batch_data_list in data:
        for d in batch_data_list:
            pair = (d.node_path, d.field_name)
            if pair in seen:
                raise ValueError(f"Duplicate batch binding: {pair}")
            seen.add(pair)

Type guard

def all_unique(data) -> bool:
    pairs = [(d.node_path, d.field_name) for lst in data for d in lst]
    return len(pairs) == len(set(pairs))

Try / catch

try:
    batch = Batch(**batch_dict)
except BatchDuplicateNodeFieldError as e:
    logger.error(f"Duplicate node/field binding: {e}")
    # deduplicate data and rebuild

Prevention

When it happens

Trigger: Adding the same node's same field twice to batch data (e.g. two collections both bound to node 'n.prompt'), often via programmatic batch construction or duplicated JSON entries.

Common situations: Copy-pasting a batch data entry and forgetting to change the node_path or field_name; scripts that loop and append the same mapping repeatedly; merging batch configs from two sources.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/d3d8fd904ccac8cb. Report an issue: GitHub.