{"record":{"id":"30b3be22c0209332","repo":"deepset-ai/haystack","slug":"the-value-of-parameter-ranking-mode-must-be-rec","errorCode":null,"errorMessage":"The value of parameter <ranking_mode> must be 'reciprocal_rank_fusion' or 'linear_score', but is currently set to '{ranking_mode}'.\nChange the <ranking_mode> value to 'reciprocal_rank_fusion' or 'linear_score' when initializing the MetaFieldRanker.","messagePattern":"The value of parameter <ranking_mode> must be 'reciprocal_rank_fusion' or 'linear_score', but is currently set to '(.+?)'\\.\nChange the <ranking_mode> value to 'reciprocal_rank_fusion' or 'linear_score' when initializing the MetaFieldRanker\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/components/rankers/meta_field.py","lineNumber":132,"sourceCode":"        top_k: int | None,\n        ranking_mode: Literal[\"reciprocal_rank_fusion\", \"linear_score\"],\n        sort_order: Literal[\"ascending\", \"descending\"],\n        missing_meta: Literal[\"drop\", \"top\", \"bottom\"],\n        meta_value_type: Literal[\"float\", \"int\", \"date\"] | None,\n    ) -> None:\n        if top_k is not None and top_k <= 0:\n            raise ValueError(f\"top_k must be > 0, but got {top_k}\")\n\n        if weight < 0 or weight > 1:\n            raise ValueError(\n                f\"Parameter <weight> must be in range [0,1] but is currently set to '{weight}'.\\n'0' disables sorting \"\n                \"by a meta field, '0.5' assigns equal weight to the previous relevance scores and the meta field, and \"\n                \"'1' ranks by the meta field only.\\nChange the <weight> parameter to a value in range 0 to 1 when \"\n                \"initializing the MetaFieldRanker.\"\n            )\n\n        if ranking_mode not in [\"reciprocal_rank_fusion\", \"linear_score\"]:\n            raise ValueError(\n                \"The value of parameter <ranking_mode> must be 'reciprocal_rank_fusion' or 'linear_score', but is \"\n                f\"currently set to '{ranking_mode}'.\\nChange the <ranking_mode> value to 'reciprocal_rank_fusion' or \"\n                \"'linear_score' when initializing the MetaFieldRanker.\"\n            )\n\n        if sort_order not in [\"ascending\", \"descending\"]:\n            raise ValueError(\n                \"The value of parameter <sort_order> must be 'ascending' or 'descending', \"\n                f\"but is currently set to '{sort_order}'.\\n\"\n                \"Change the <sort_order> value to 'ascending' or 'descending' when initializing the \"\n                \"MetaFieldRanker.\"\n            )\n\n        if missing_meta not in [\"drop\", \"top\", \"bottom\"]:\n            raise ValueError(\n                \"The value of parameter <missing_meta> must be 'drop', 'top', or 'bottom', \"\n                f\"but is currently set to '{missing_meta}'.\\n\"\n                \"Change the <missing_meta> value to 'drop', 'top', or 'bottom' when initializing the \"","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/rankers/meta_field.py#L114-L150","documentation":"MetaFieldRanker._validate_params rejects any ranking_mode other than 'reciprocal_rank_fusion' or 'linear_score'. This literal-typed parameter selects the score-combination algorithm; an unknown value cannot be dispatched and raises ValueError in both __init__ and run.","triggerScenarios":"MetaFieldRanker(ranking_mode='rrf'), 'score', 'linear', or any misspelled/unrelated string; typing only catches this statically with a type checker, not at runtime.","commonSituations":"Abbreviating mode names in configs ('rrf'); copying a mode string from another ranker component (e.g. a SentimentRanker option); YAML values with different casing ('Linear_Score').","solutions":["Use exactly 'reciprocal_rank_fusion' or 'linear_score' (lowercase).","Compare against the Literal type in the component's signature or docs and fix the spelling.","If the value comes from config, map/normalize it before constructing the ranker."],"exampleFix":"// before\nranker = MetaFieldRanker(ranking_mode=\"rrf\")\n// after\nranker = MetaFieldRanker(ranking_mode=\"reciprocal_rank_fusion\")","handlingStrategy":"validation","validationCode":"VALID_RANKING_MODES = (\"reciprocal_rank_fusion\", \"linear_score\")\nif ranking_mode not in VALID_RANKING_MODES:\n    raise ValueError(f\"ranking_mode must be one of {VALID_RANKING_MODES}, got {ranking_mode!r}\")","typeGuard":"def is_valid_ranking_mode(v) -> bool:\n    return v in (\"reciprocal_rank_fusion\", \"linear_score\")","tryCatchPattern":"try:\n    ranker = MetaFieldRanker(ranking_mode=mode)\nexcept ValueError as e:\n    logger.warning(\"Invalid ranking_mode %s; defaulting to reciprocal_rank_fusion\", e)\n    ranker = MetaFieldRanker(ranking_mode=\"reciprocal_rank_fusion\")","preventionTips":["Copy literal strings from the component signature, not from memory.","Use a type checker (mypy/pyright) so Literal violations fail statically.","Normalize config values (lowercase, strip) and validate against the allowed set before init."],"tags":["python","validation","ranker","enum-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}