deepset-ai/haystack · error · ValueError

The value of parameter <missing_meta> must be 'drop', 'top',

Error message

The value of parameter <missing_meta> must be 'drop', 'top', or 'bottom', but is currently set to '{missing_meta}'.
Change the <missing_meta> value to 'drop', 'top', or 'bottom' when initializing the MetaFieldRanker.

What it means

MetaFieldRanker._validate_params rejects any missing_meta value other than 'drop', 'top', or 'bottom'. This parameter controls where documents lacking the ranker's meta field are placed; an unknown value raises ValueError in both __init__ and run.

Source

Thrown at haystack/components/rankers/meta_field.py:147

            )

        if ranking_mode not in ["reciprocal_rank_fusion", "linear_score"]:
            raise ValueError(
                "The value of parameter <ranking_mode> must be 'reciprocal_rank_fusion' or 'linear_score', but is "
                f"currently set to '{ranking_mode}'.\nChange the <ranking_mode> value to 'reciprocal_rank_fusion' or "
                "'linear_score' when initializing the MetaFieldRanker."
            )

        if sort_order not in ["ascending", "descending"]:
            raise ValueError(
                "The value of parameter <sort_order> must be 'ascending' or 'descending', "
                f"but is currently set to '{sort_order}'.\n"
                "Change the <sort_order> value to 'ascending' or 'descending' when initializing the "
                "MetaFieldRanker."
            )

        if missing_meta not in ["drop", "top", "bottom"]:
            raise ValueError(
                "The value of parameter <missing_meta> must be 'drop', 'top', or 'bottom', "
                f"but is currently set to '{missing_meta}'.\n"
                "Change the <missing_meta> value to 'drop', 'top', or 'bottom' when initializing the "
                "MetaFieldRanker."
            )

        if meta_value_type not in ["float", "int", "date", None]:
            raise ValueError(
                "The value of parameter <meta_value_type> must be 'float', 'int', 'date' or None but is "
                f"currently set to '{meta_value_type}'.\n"
                "Change the <meta_value_type> value to 'float', 'int', 'date' or None when initializing the "
                "MetaFieldRanker."
            )

    @component.output_types(documents=list[Document])
    def run(
        self,
        documents: list[Document],

View on GitHub (pinned to e318778c9b)

Solutions

  1. Use exactly 'drop', 'top', or 'bottom' (lowercase).
  2. Map external config values to the supported literals before construction (e.g. 'last'->'bottom', 'remove'->'drop').
  3. Strip whitespace and lowercase config-derived values before passing them in.

Example fix

// before
ranker = MetaFieldRanker(missing_meta="skip")
// after
ranker = MetaFieldRanker(missing_meta="drop")
Defensive patterns

Strategy: validation

Validate before calling

VALID_MISSING_META = ("drop", "top", "bottom")
if missing_meta not in VALID_MISSING_META:
    raise ValueError(f"missing_meta must be one of {VALID_MISSING_META}, got {missing_meta!r}")

Type guard

def is_valid_missing_meta(v) -> bool:
    return v in ("drop", "top", "bottom")

Try / catch

try:
    ranker = MetaFieldRanker(missing_meta=mm)
except ValueError as e:
    logger.warning("Invalid missing_meta %s; defaulting to 'drop'", e)
    ranker = MetaFieldRanker(missing_meta="drop")

Prevention

When it happens

Trigger: MetaFieldRanker(missing_meta='skip'), 'first', 'last', 'none', or any misspelled string; the check is a case-sensitive membership test against ['drop', 'top', 'bottom'].

Common situations: Using synonyms like 'remove'/'last' in configs; porting settings from another ranker with similar-but-different option names; typos such as 'bottom_' or extra whitespace from YAML parsing.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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