deepset-ai/haystack · error · PipelineInvalidPipelineSnapshotError

Invalid pipeline snapshot: components {invalid_component_vis

Error message

Invalid pipeline snapshot: components {invalid_component_visits} in 'component_visits' are not part of the current pipeline.

What it means

_validate_pipeline_snapshot_against_pipeline raises PipelineInvalidPipelineSnapshotError when the snapshot's component_visits dict contains component names absent from the current pipeline graph. Visit counts track how many times each component has run and must refer to real components for resume logic.

Source

Thrown at haystack/core/pipeline/breakpoint.py:88

    if invalid_ordered_components:
        raise PipelineInvalidPipelineSnapshotError(
            f"Invalid pipeline snapshot: components {invalid_ordered_components} in 'ordered_component_names' "
            f"are not part of the current pipeline."
        )

    # Check if the original_input_data is valid components in the pipeline
    serialized_input_data = pipeline_snapshot.original_input_data["serialized_data"]
    invalid_input_data = set(serialized_input_data.keys()) - valid_components
    if invalid_input_data:
        raise PipelineInvalidPipelineSnapshotError(
            f"Invalid pipeline snapshot: components {invalid_input_data} in 'input_data' "
            f"are not part of the current pipeline."
        )

    # Validate 'component_visits'
    invalid_component_visits = set(pipeline_state.component_visits.keys()) - valid_components
    if invalid_component_visits:
        raise PipelineInvalidPipelineSnapshotError(
            f"Invalid pipeline snapshot: components {invalid_component_visits} in 'component_visits' "
            f"are not part of the current pipeline."
        )

    component_name = pipeline_snapshot.break_point.component_name
    visit_count = pipeline_snapshot.pipeline_state.component_visits[component_name]

    logger.info(
        "Resuming pipeline from {component} with visit count {visits}", component=component_name, visits=visit_count
    )


def load_pipeline_snapshot(file_path: str | Path) -> PipelineSnapshot:
    """
    Load a saved pipeline snapshot.

    :param file_path: Path to the pipeline_snapshot file.
    :returns:

View on GitHub (pinned to e318778c9b)

Solutions

  1. Regenerate the snapshot with the current pipeline so component_visits keys are valid.
  2. Delete entries for non-existent components from component_visits (keeping at least the break_point component's count).
  3. Rename the stale keys to the current component names if they were merely renamed.

Example fix

// before
snapshot.pipeline_state.component_visits = {"old_llm": 2}
// after
snapshot.pipeline_state.component_visits = {"llm": 2}
Defensive patterns

Strategy: validation

Validate before calling

invalid = set(snapshot.pipeline_state.component_visits) - set(pipeline.graph.nodes)
assert not invalid, f"component_visits references unknown components: {invalid}"

Type guard

def visits_valid(snapshot, pipeline) -> bool:
    return set(snapshot.pipeline_state.component_visits) <= set(pipeline.graph.nodes)

Try / catch

try:
    result = pipeline.run(data, pipeline_snapshot=snapshot)
except PipelineInvalidPipelineSnapshotError as e:
    logger.error("Snapshot component_visits invalid: %s", e)

Prevention

When it happens

Trigger: Resuming a snapshot saved from a different or edited pipeline; hand-editing the snapshot's component_visits keys; deserializing a snapshot after components were renamed.

Common situations: Cross-pipeline snapshot reuse; pipeline definition changed between save and resume; manually authored snapshot files in tests or tooling.

Related errors


AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30). Data as JSON: /api/errors/62d19af4a97dafaf. Report an issue: GitHub.