{"record":{"id":"5e00d2682735e15c","repo":"deepset-ai/haystack","slug":"invalid-output-format-output-format-provided","errorCode":null,"errorMessage":"Invalid output format '{output_format}' provided. Choose from 'json', 'csv', or 'df'.","messagePattern":"Invalid output format '(.+?)' provided\\. Choose from 'json', 'csv', or 'df'\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"haystack/evaluation/eval_run_result.py","lineNumber":120,"sourceCode":"    ) -> Union[str, \"DataFrame\", dict[str, list[Any]]]:\n        \"\"\"\n        Handles output formatting based on `output_format`.\n\n        :returns: DataFrame for 'df', dict for 'json', or confirmation message for 'csv'\n        \"\"\"\n        if output_format == \"json\":\n            return data\n\n        if output_format == \"df\":\n            pandas_import.check()\n            return DataFrame(data)\n\n        if output_format == \"csv\":\n            if not csv_file:\n                raise ValueError(\"A file path must be provided in 'csv_file' parameter to save the CSV output.\")\n            return EvaluationRunResult._write_to_csv(csv_file, data)\n\n        raise ValueError(f\"Invalid output format '{output_format}' provided. Choose from 'json', 'csv', or 'df'.\")\n\n    def aggregated_report(\n        self, output_format: Literal[\"json\", \"csv\", \"df\"] = \"json\", csv_file: str | None = None\n    ) -> Union[dict[str, list[Any]], \"DataFrame\", str]:\n        \"\"\"\n        Generates a report with aggregated scores for each metric.\n\n        :param output_format: The output format for the report, \"json\", \"csv\", or \"df\", default to \"json\".\n        :param csv_file: Filepath to save CSV output if `output_format` is \"csv\", must be provided.\n\n        :returns:\n            JSON or DataFrame with aggregated scores, in case the output is set to a CSV file, a message confirming the\n            successful write or an error message.\n        \"\"\"\n        results = {k: v[\"score\"] for k, v in self.results.items()}\n        data = {\"metrics\": list(results.keys()), \"score\": list(results.values())}\n        return self._handle_output(data, output_format, csv_file)\n","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/evaluation/eval_run_result.py#L102-L138","documentation":"_handle_output only supports 'json', 'csv', and 'df' output formats. Any other string (including case variants like 'CSV' or 'dataframe') reaches the final fallthrough and raises this ValueError listing the valid options.","triggerScenarios":"Calling aggregated_report/detailed_report/comparative_detailed_report with output_format set to any value other than 'json', 'csv', or 'df' — e.g. 'dataframe', 'JSON', 'pandas', or a None value.","commonSituations":"Typo or wrong-cased format string; passing a user-supplied format option through without validation; confusing the format name with the library name ('pandas' instead of 'df').","solutions":["Use exactly one of 'json', 'csv', or 'df' (lowercase).","Normalize input: output_format = output_format.lower() before calling.","Add a whitelist check in calling code to fail fast with a friendly message."],"exampleFix":"// before\nrun.aggregated_report(output_format='dataframe')\n// after\nrun.aggregated_report(output_format='df')","handlingStrategy":"validation","validationCode":"VALID_FORMATS = {'json', 'csv', 'df'}\nif output_format not in VALID_FORMATS:\n    raise ValueError(f'output_format must be one of {VALID_FORMATS}')","typeGuard":"from typing import Literal\nOutputFormat = Literal['json', 'csv', 'df']\ndef is_valid_format(f: str) -> bool:\n    return f in ('json', 'csv', 'df')","tryCatchPattern":"try:\n    report = run.aggregated_report(output_format=user_format)\nexcept ValueError as e:\n    if 'Invalid output format' in str(e):\n        report = run.aggregated_report(output_format='json')\n    else:\n        raise","preventionTips":["Use Literal['json','csv','df'] type annotations so type checkers catch bad values","Normalize user-supplied formats with .lower() and map aliases ('dataframe' -> 'df')","Centralize report generation in one helper that validates the format once"],"tags":["python","argument-validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}