{"record":{"id":"de4b7f01d4b1dfac","repo":"databendlabs/databend","slug":"expected-csv-params","errorCode":null,"errorMessage":"expected csv params","messagePattern":"expected csv params","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/meta/app/src/principal/file_format.rs","lineNumber":1309,"sourceCode":"    use super::*;\n\n    fn get_text_params(options: BTreeMap<String, String>) -> TextFileFormatParams {\n        let params =\n            FileFormatParams::try_from_reader(FileFormatOptionsReader::from_map(options), false)\n                .expect(\"tsv file format options should parse\");\n        match params {\n            FileFormatParams::Text(v) => v,\n            _ => unreachable!(\"expected tsv params\"),\n        }\n    }\n\n    fn get_csv_params(options: BTreeMap<String, String>) -> CsvFileFormatParams {\n        let params =\n            FileFormatParams::try_from_reader(FileFormatOptionsReader::from_map(options), false)\n                .expect(\"csv file format options should parse\");\n        match params {\n            FileFormatParams::Csv(v) => v,\n            _ => unreachable!(\"expected csv params\"),\n        }\n    }\n\n    #[test]\n    fn test_text_field_delimiter_empty_string() {\n        let mut options = BTreeMap::new();\n        options.insert(\"type\".to_string(), \"TEXT\".to_string());\n        options.insert(\"field_delimiter\".to_string(), \"\".to_string());\n\n        let params = get_text_params(options);\n        assert_eq!(params.field_delimiter, \"\".to_string());\n    }\n\n    #[test]\n    fn test_text_extended_options() {\n        let mut options = BTreeMap::new();\n        options.insert(\"type\".to_string(), \"TEXT\".to_string());\n        options.insert(","sourceCodeStart":1291,"sourceCodeEnd":1327,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/app/src/principal/file_format.rs#L1291-L1327","documentation":"In the unit-test helper get_csv_params, parsed FileFormatParams are narrowed to CsvFileFormatParams and any other variant panics with unreachable!(\"expected csv params\"). It indicates the supplied options did not parse into the Csv variant the test requires.","triggerScenarios":"Feeding get_csv_params an options map that parses to FileFormatParams::Text, Json, etc. — for instance a wrong TYPE value, missing format key, or modified parsing that reclassifies these options.","commonSituations":"Option-parsing refactors that change which variant CSV options map to; reusing another test's options map; renaming CSV format identifiers.","solutions":["Verify the options map includes the correct CSV format/TYPE value so parsing yields FileFormatParams::Csv.","Make the helper panic with the actual variant for diagnosability.","Fix the parser regression if these options are meant to be Csv."],"exampleFix":"// before\nmatch params {\n    FileFormatParams::Csv(v) => v,\n    _ => unreachable!(\"expected csv params\"),\n}\n// after\nmatch params {\n    FileFormatParams::Csv(v) => v,\n    other => panic!(\"expected csv params, got {:?}\", other),\n}","handlingStrategy":"validation","validationCode":"let parsed = FileFormatParams::try_from_reader(FileFormatOptionsReader::from_map(options.clone()), false)\n    .expect(\"options should parse\");\nassert!(matches!(parsed, FileFormatParams::Csv(_)), \"options must yield Csv params: {:?}\", parsed);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure CSV test options set the correct TYPE value.","Update helpers to report the unexpected variant on failure.","Run the file-format test suite after parser refactors.","Avoid reusing option maps across different format tests."],"tags":["rust","test","panic","file-format","csv"],"backgroundTag":"internal-invariant-violation","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}