{"record":{"id":"89fac87da64b8b1b","repo":"deepset-ai/haystack","slug":"the-value-of-parameter-sort-order-must-be-ascen","errorCode":null,"errorMessage":"The value of parameter <sort_order> must be 'ascending' or 'descending', but is currently set to '{sort_order}'.\nChange the <sort_order> value to 'ascending' or 'descending' when initializing the MetaFieldRanker.","messagePattern":"The value of parameter <sort_order> must be 'ascending' or 'descending', but is currently set to '(.+?)'\\.\nChange the <sort_order> value to 'ascending' or 'descending' when initializing the MetaFieldRanker\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/components/rankers/meta_field.py","lineNumber":139,"sourceCode":"            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 \"\n                \"MetaFieldRanker.\"\n            )\n\n        if meta_value_type not in [\"float\", \"int\", \"date\", None]:\n            raise ValueError(\n                \"The value of parameter <meta_value_type> must be 'float', 'int', 'date' or None but is \"\n                f\"currently set to '{meta_value_type}'.\\n\"","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/rankers/meta_field.py#L121-L157","documentation":"MetaFieldRanker._validate_params rejects any sort_order other than 'ascending' or 'descending'. Sort order determines whether the meta field is ranked smallest-first or largest-first; unknown values raise ValueError in both __init__ and run.","triggerScenarios":"MetaFieldRanker(sort_order='asc'), 'Ascending', 'desc', or any other string; the literal check is case-sensitive and requires the full words.","commonSituations":"Using SQL-style abbreviations ('asc'/'desc') in configs; UI code passing arbitrary sort strings; locale/case differences when the value is loaded from a file.","solutions":["Use exactly 'ascending' or 'descending' (lowercase, full word).","Normalize shorthand at the call site: map 'asc'->'ascending', 'desc'->'descending'.","Add a config-level choice validation before constructing the ranker."],"exampleFix":"// before\nranker = MetaFieldRanker(sort_order=\"asc\")\n// after\nranker = MetaFieldRanker(sort_order=\"ascending\")","handlingStrategy":"validation","validationCode":"VALID_SORT_ORDERS = (\"ascending\", \"descending\")\nif sort_order not in VALID_SORT_ORDERS:\n    raise ValueError(f\"sort_order must be one of {VALID_SORT_ORDERS}, got {sort_order!r}\")","typeGuard":"def is_valid_sort_order(v) -> bool:\n    return v in (\"ascending\", \"descending\")","tryCatchPattern":"try:\n    ranker = MetaFieldRanker(sort_order=order)\nexcept ValueError:\n    order = {\"asc\": \"ascending\", \"desc\": \"descending\"}.get(order, \"descending\")\n    ranker = MetaFieldRanker(sort_order=order)","preventionTips":["Expand 'asc'/'desc' shorthands via a mapping before passing them in.","Keep sort options in a shared enum/Literal reused by UI and config.","Remember the check is case-sensitive; normalize case first."],"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"}