{"record":{"id":"b245c6e32204110e","repo":"deepset-ai/haystack","slug":"a-file-path-must-be-provided-in-csv-file-paramet","errorCode":null,"errorMessage":"A file path must be provided in 'csv_file' parameter to save the CSV output.","messagePattern":"A file path must be provided in 'csv_file' parameter to save the CSV output\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"haystack/evaluation/eval_run_result.py","lineNumber":117,"sourceCode":"    @staticmethod\n    def _handle_output(\n        data: dict[str, list[Any]], output_format: Literal[\"json\", \"csv\", \"df\"] = \"csv\", csv_file: str | None = None\n    ) -> 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()}","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/evaluation/eval_run_result.py#L99-L135","documentation":"When requesting CSV output from aggregated_report, detailed_report, or comparative_detailed_report, a destination path must be supplied via the csv_file parameter. Since csv_file defaults to None, choosing output_format='csv' without a path raises this ValueError because there is nowhere to write the file.","triggerScenarios":"Calling run.aggregated_report(output_format='csv') (or detailed_report / comparative_detailed_report) without passing csv_file='path/to/file.csv'.","commonSituations":"Switching output_format from 'json'/'df' to 'csv' in existing code and forgetting the extra parameter; scripting report generation where the path variable was empty or None.","solutions":["Pass csv_file='/path/to/report.csv' when using output_format='csv'.","Default to output_format='json' or 'df' if no file output is needed.","Wrap the call and validate csv_file is set before invoking."],"exampleFix":"// before\nrun.aggregated_report(output_format='csv')\n// after\nrun.aggregated_report(output_format='csv', csv_file='report.csv')","handlingStrategy":"validation","validationCode":"if output_format == 'csv' and not csv_file:\n    raise ValueError('csv_file path required for CSV output')","typeGuard":"null","tryCatchPattern":"try:\n    report = run.aggregated_report(output_format='csv', csv_file=csv_file)\nexcept ValueError as e:\n    if \"csv_file\" in str(e):\n        report = run.aggregated_report(output_format='json')\n    else:\n        raise","preventionTips":["Always supply csv_file when output_format='csv'","Resolve the output path from config with a non-empty default","Add a small wrapper that sets a default filename per report type"],"tags":["python","csv","argument-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}