deepset-ai/haystack · error · ValueError
The value of parameter <meta_value_type> must be 'float', 'i
Error message
The value of parameter <meta_value_type> must be 'float', 'int', 'date' or None but is currently set to '{meta_value_type}'.
Change the <meta_value_type> value to 'float', 'int', 'date' or None when initializing the MetaFieldRanker. What it means
MetaFieldRanker sorts documents by a metadata field, and meta_value_type tells it how to parse the values (as float, int, or date). The library only accepts 'float', 'int', 'date' or None; anything else makes sorting semantics ambiguous, so _validate_params raises a ValueError at init or run time.
Source
Thrown at haystack/components/rankers/meta_field.py:155
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],
top_k: int | None = None,
weight: float | None = None,
ranking_mode: Literal["reciprocal_rank_fusion", "linear_score"] | None = None,
sort_order: Literal["ascending", "descending"] | None = None,
missing_meta: Literal["drop", "top", "bottom"] | None = None,
meta_value_type: Literal["float", "int", "date"] | None = None,
) -> dict[str, Any]:
"""View on GitHub (pinned to e318778c9b)
Solutions
- Set meta_value_type to exactly one of 'float', 'int', 'date', or omit it (None)
- Fix the string casing/spelling (Python string compare is case-sensitive)
- If values are strings, remove meta_value_type or use 'date' with ISO-formatted date strings
Example fix
// before ranker = MetaFieldRanker(meta_field="rating", meta_value_type="number") // after ranker = MetaFieldRanker(meta_field="rating", meta_value_type="float")
Defensive patterns
Strategy: validation
Validate before calling
VALID = {"float", "int", "date", None}
if meta_value_type not in VALID:
raise ValueError(f"meta_value_type must be one of 'float','int','date',None, got {meta_value_type!r}") Type guard
def is_valid_meta_value_type(t: object) -> bool:
return t in ("float", "int", "date", None) Try / catch
try:
ranker = MetaFieldRanker(meta_field="rating", meta_value_type=t)
except ValueError as e:
logger.error("Invalid meta_value_type: %s", e)
ranker = MetaFieldRanker(meta_field="rating") # default None Prevention
- Keep meta_value_type in a constant set shared with validation
- Only use values from the documented enum
- Cover ranker init in unit tests with config loading
When it happens
Trigger: MetaFieldRanker(meta_value_type="str") or any misspelled/other value such as "number", "Float", "datetime" — validated in __init__ and again in run().
Common situations: Typo in the type string, copying config from another ranker, using a type name from another library (e.g. 'datetime' or 'number'), or programmatic pipeline YAML with a wrong value.
Understand the failure class
Background: "must be positive", "Invalid value": how libraries reject invalid parameter values (ValueError, ArgumentError, INVALID_PARAMETER_VALUE) — this error's family across 28 libraries.
Related errors
- Invalid value for word_count_threshold: {word_count_threshol
- top_k must be > 0, but got {top_k}
- top_k must be > 0, but got {top_k}
- Parameter <weight> must be in range [0,1] but is currently s
- The value of parameter <ranking_mode> must be 'reciprocal_ra
AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30).
Data as JSON: /api/errors/5a10b476d4539c0c.
Report an issue: GitHub.