{"record":{"id":"d907f6131d332a41","repo":"FlowiseAI/Flowise","slug":"expected-string-at-position-i-got-typeof-pag-d907f6","errorCode":null,"errorMessage":"Expected string, at position ${i} got ${typeof pageContent}","messagePattern":"Expected string, at position (.+?) got (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/Jsonlines/Jsonlines.ts","lineNumber":263,"sourceCode":"        return [{ pageContent: raw, metadata: {} }]\n    }\n\n    public async load(): Promise<Document[]> {\n        let text: string\n        let metadata: Record<string, string>\n        if (typeof this.filePathOrBlob === 'string') {\n            const { readFile } = await TextLoader.imports()\n            text = await readFile(this.filePathOrBlob, 'utf8')\n            metadata = { source: this.filePathOrBlob }\n        } else {\n            text = await this.filePathOrBlob.text()\n            metadata = { source: 'blob', blobType: this.filePathOrBlob.type }\n        }\n        const parsed = await this.parse(text)\n        parsed.forEach((parsedData, i) => {\n            const { pageContent } = parsedData\n            if (typeof pageContent !== 'string') {\n                throw new Error(`Expected string, at position ${i} got ${typeof pageContent}`)\n            }\n        })\n        return parsed.map((parsedData, i) => {\n            const { pageContent, metadata: additionalMetadata } = parsedData\n            return new Document({\n                pageContent,\n                metadata:\n                    parsed.length === 1\n                        ? { ...metadata, ...additionalMetadata }\n                        : {\n                              ...metadata,\n                              line: i + 1,\n                              ...additionalMetadata\n                          }\n            })\n        })\n    }\n","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/Jsonlines/Jsonlines.ts#L245-L281","documentation":"Same type-check as Json.ts but in the JSONLines loader: each parsed record's pageContent must be a string. Fires when a JSONL pointer resolves to a non-string value (number, boolean, array, object, null) on any line.","triggerScenarios":"A JSONL pointer like '/value' resolves to a number on some line; the pointer is omitted so each parsed line (an object) becomes pageContent; a malformed JSONL line parses to null.","commonSituations":"Streaming logs where the 'message' field is sometimes a string and sometimes an object; pointing at a numeric metric field; mixed-schema JSONL exports.","solutions":["Inspect line i+1 of the .jsonl file — the pointed-to field is not a string.","Point the pointer at a guaranteed string field across all lines.","Normalize the JSONL upstream so every line's target field is a string.","Drop or transform non-conforming lines before loading."],"exampleFix":"// before - pointer '/count' is numeric in some lines\nnew JSONLinesLoader(file, '/count')\n// after - target the text field\nnew JSONLinesLoader(file, '/message')","handlingStrategy":"type-guard","validationCode":"// Validate every line of the JSONL resolves to a string at the pointer\nfunction validateJsonlPointers(text, pointer) {\n  const jp = require('jsonpointer')\n  const lines = text.split(/\\r?\\n/).filter(Boolean)\n  lines.forEach((line, i) => {\n    const rec = JSON.parse(line)\n    const v = pointer ? jp.get(rec, pointer) : rec\n    if (typeof v !== 'string') throw new Error(`line ${i + 1}: pointer '${pointer}' is ${typeof v}, not string`)\n  })\n}","typeGuard":"function isStringRecord(value) { return typeof value === 'string' }","tryCatchPattern":"try {\n  return await jsonLinesLoader.load()\n} catch (e) {\n  if (/Expected string, at position/.test(e.message)) {\n    throw new Error('JSONL target field is not a string on some line — check pointer', { cause: e })\n  }\n  throw e\n}","preventionTips":["Point the JSONL pointer at a consistently string field.","Pre-scan the file line by line to confirm types.","Normalize or drop non-conforming lines upstream.","Use a schema validator on streaming JSONL."],"tags":["json","jsonl","type-check","jsonpointer","validation"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}