{"record":{"id":"f9af7cda278092d9","repo":"FlowiseAI/Flowise","slug":"unable-to-resolve-fields-from-header","errorCode":null,"errorMessage":"Unable to resolve fields from header.","messagePattern":"Unable to resolve fields from header\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/Csv/CsvLoader.ts","lineNumber":55,"sourceCode":"     * the `column` option is not specified, it converts each row of the CSV\n     * data into key/value pairs and joins them with newline characters.\n     * @param raw The raw CSV data to be parsed.\n     * @returns An array of strings representing the pageContent of each document.\n     */\n    async parse(raw: string): Promise<string[]> {\n        const { column, separator } = this.options\n\n        const {\n            data: parsed,\n            meta: { fields = [] }\n        } = Papa.parse<{ [K: string]: string }>(raw.trim(), {\n            delimiter: separator,\n            header: true\n        })\n\n        if (column !== undefined) {\n            if (!fields.length) {\n                throw new Error(`Unable to resolve fields from header.`)\n            }\n\n            let searchIdx = column\n\n            if (typeof column == 'number') {\n                searchIdx = fields[column]\n            }\n\n            if (!fields.includes(searchIdx as string)) {\n                throw new Error(`Column ${column} not found in CSV file.`)\n            }\n\n            // Note TextLoader will raise an exception if the value is null.\n            return parsed.map((row) => row[searchIdx])\n        }\n\n        return parsed.map((row) => fields.map((key) => `${key.trim() || '_0'}: ${row[key]?.trim()}`).join('\\n'))\n    }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/Csv/CsvLoader.ts#L37-L73","documentation":"CsvLoader calls Papa.parse with header:true and reads fields from meta. If a column selector was requested but fields came back empty, the header could not be resolved. fields is empty when the input is blank, contains only a delimiter row, has no recognizable header, or uses a wrong separator that makes Papa treat everything as one column with an empty name.","triggerScenarios":"Empty file passed to the loader; file is binary/garbage so Papa yields no rows; separator option is wrong (e.g., ';' set but file is comma-delimited) collapsing everything into one unnamed field; file starts with a blank line so header detection fails.","commonSituations":"Upstream TextLoader received a non-CSV blob; user uploaded an .xlsx renamed to .csv; CSV uses CRLF and a stray quote confuses the parser.","solutions":["Open the file in a text editor and confirm it has a real header row.","Verify the separator option matches the file (',', ';', '\\t', '|').","Strip any BOM or leading blank lines from the source before parsing.","If loading from a Blob, ensure the upstream actually produced CSV text."],"exampleFix":"// before\nconst { data: parsed, meta: { fields = [] } } = Papa.parse(raw.trim(), {\n  delimiter: separator, header: true\n})\nif (column !== undefined && !fields.length) {\n  throw new Error(`Unable to resolve fields from header.`)\n}\n// after - include a preview and try auto-detecting delimiter\nconst { data: parsed, meta: { fields = [], delimiter: usedDelimiter } } =\n  Papa.parse(raw.trim(), { header: true })\nif (column !== undefined && !fields.length) {\n  throw new Error(`Unable to resolve fields from header (detected delimiter '${usedDelimiter}', preview: ${raw.slice(0, 120)})`)\n}","handlingStrategy":"validation","validationCode":"import Papa from 'papaparse'\n\nfunction assertCsvHasHeader(raw: string, separator?: string): string[] {\n  const { meta: { fields = [] } } = Papa.parse(raw.trim(), { delimiter: separator, header: true, preview: 1 })\n  if (!fields.length) throw new Error('CSV has no parseable header row - check content and separator')\n  return fields\n}\n// const fields = assertCsvHasHeader(raw, separator) before passing column","typeGuard":"function csvHasFields(raw: string, separator?: string): boolean {\n  const { meta: { fields = [] } } = Papa.parse(raw.trim(), { delimiter: separator, header: true, preview: 1 })\n  return fields.length > 0\n}","tryCatchPattern":null,"preventionTips":["Confirm the file has a real header row and is not empty.","Match the separator option to the file's delimiter.","Strip BOM and leading blank lines upstream."],"tags":["csv","parsing","validation","papaparse"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}