deepset-ai/haystack · error · PipelineError

Missing 'type' in component '{name}'

Error message

Missing 'type' in component '{name}'

What it means

Pipeline.from_dict deserializes each entry under 'components'; every serialized component must declare its 'type' (the registry key). When the dict lacks 'type', Haystack cannot look the component up and raises PipelineError naming the offending component.

Source

Thrown at haystack/core/pipeline/base.py:235

        cls: type[T], data: dict[str, Any], callbacks: DeserializationCallbacks | None = None, **kwargs: Any
    ) -> T:
        data_copy = _deepcopy_with_exceptions(data)  # to prevent modification of original data
        metadata = data_copy.get("metadata", {})
        max_runs_per_component = data_copy.get("max_runs_per_component", 100)
        connection_type_validation = data_copy.get("connection_type_validation", True)
        pipe = cls(
            metadata=metadata,
            max_runs_per_component=max_runs_per_component,
            connection_type_validation=connection_type_validation,
        )
        components_to_reuse = kwargs.get("components", {})
        for name, component_data in data_copy.get("components", {}).items():
            if name in components_to_reuse:
                # Reuse an instance
                instance = components_to_reuse[name]
            else:
                if "type" not in component_data:
                    raise PipelineError(f"Missing 'type' in component '{name}'")

                component_type = component_data["type"]
                if isinstance(component_type, str) and "." in component_type:
                    _check_module_allowed(component_type.rsplit(".", 1)[0])

                if component_type not in component.registry:
                    try:
                        # Import the module first...
                        module, _ = component_type.rsplit(".", 1)
                        logger.debug("Trying to import module {module_name}", module_name=module)
                        type_serialization.thread_safe_import(module)
                        # ...then try again
                        if component_type not in component.registry:
                            raise PipelineError(  # noqa: TRY301
                                f"Successfully imported module '{module}' but couldn't find "
                                f"'{component_type}' in the component registry.\n"
                                f"The component might be registered under a different path. "
                                f"Here are the registered components:\n {list(component.registry.keys())}\n"

View on GitHub (pinned to e318778c9b)

Solutions

  1. Add the missing 'type' key to the component entry, e.g. type: haystack.components.rankers.TransformersSimilarityRanker
  2. Re-dump the pipeline with pipe.dumps()/yaml to regenerate a valid definition
  3. Validate the YAML against a known-good pipeline file to spot omissions

Example fix

// before
components:
  ranker:
    init_parameters:
      top_k: 10

// after
components:
  ranker:
    type: haystack.components.rankers.TransformersSimilarityRanker
    init_parameters:
      top_k: 10
Defensive patterns

Strategy: validation

Validate before calling

def validate_pipeline_yaml(data: dict) -> list[str]:
    problems = []
    for name, comp in data.get("components", {}).items():
        if "type" not in comp:
            problems.append(f"Component '{name}' is missing the 'type' key")
    return problems

Try / catch

try:
    pipe = Pipeline.from_dict(data)
except PipelineError as e:
    if "Missing 'type'" in str(e):
        logging.error("Add the 'type' key to the component entry: %s", e)

Prevention

When it happens

Trigger: Loading a YAML/JSON pipeline definition where a component entry in 'components' omits the 'type' key, e.g. components: {ranker: {init_parameters: {...}}} with no type field.

Common situations: Hand-editing YAML and deleting the type line; exporting tools producing incomplete YAML; template placeholders where 'type' is expected to be filled in but isn't; truncated or corrupted pipeline files.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


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