{"record":{"id":"decc96d612ec4165","repo":"databendlabs/databend","slug":"expected-tsv-params","errorCode":null,"errorMessage":"expected tsv params","messagePattern":"expected tsv params","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/meta/app/src/principal/file_format.rs","lineNumber":1299,"sourceCode":"                ErrorCode::InvalidArgument(format!(\n                    \"Invalid option value: NULL_IF is currently set to {s} (in JSON). The valid values are a list of strings.\"\n                )))?;\n            Ok(values)\n        }\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    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());","sourceCodeStart":1281,"sourceCodeEnd":1317,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/app/src/principal/file_format.rs#L1281-L1317","documentation":"In a unit test helper get_text_params, options are parsed into FileFormatParams and then narrowed to TextFileFormatParams; any non-Text result triggers unreachable!(\"expected tsv params\"). It signals the test built options that do not produce the Text (TSV) variant it expects.","triggerScenarios":"Passing a BTreeMap of options to get_text_params whose parsed FileFormatParams is not FileFormatParams::Text — e.g. a TYPE/format key set to CSV or missing entirely, or new option parsing that maps these options to a different variant.","commonSituations":"Adding or changing file-format option parsing so TSV options now resolve to another variant; copy-pasting options from a CSV test into the TSV helper; a rename of the format identifier for text formats.","solutions":["Inspect the failing options map and ensure the format/TYPE option resolves to Text (TSV).","Update the helper to panic with the actual parsed variant so failures are diagnosable.","Fix the option-parsing regression if these options should legitimately parse to Text."],"exampleFix":"// before\nmatch params {\n    FileFormatParams::Text(v) => v,\n    _ => unreachable!(\"expected tsv params\"),\n}\n// after\nmatch params {\n    FileFormatParams::Text(v) => v,\n    other => panic!(\"expected tsv 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::Text(_)), \"options must yield Text params: {:?}\", parsed);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep TSV test options minimal and explicit about the format type.","Panic with the actual parsed variant (not bare unreachable!) for diagnosability.","Re-check test helpers after any file-format option-parsing change.","Copy options only between tests of the same format."],"tags":["rust","test","panic","file-format","tsv"],"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"}