FlowiseAI/Flowise · error · Error
Expected string, at position ${i} got ${typeof pageContent}
Error message
Expected string, at position ${i} got ${typeof pageContent} What it means
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.
Source
Thrown at packages/components/nodes/documentloaders/Jsonlines/Jsonlines.ts:263
return [{ pageContent: raw, metadata: {} }]
}
public async load(): Promise<Document[]> {
let text: string
let metadata: Record<string, string>
if (typeof this.filePathOrBlob === 'string') {
const { readFile } = await TextLoader.imports()
text = await readFile(this.filePathOrBlob, 'utf8')
metadata = { source: this.filePathOrBlob }
} else {
text = await this.filePathOrBlob.text()
metadata = { source: 'blob', blobType: this.filePathOrBlob.type }
}
const parsed = await this.parse(text)
parsed.forEach((parsedData, i) => {
const { pageContent } = parsedData
if (typeof pageContent !== 'string') {
throw new Error(`Expected string, at position ${i} got ${typeof pageContent}`)
}
})
return parsed.map((parsedData, i) => {
const { pageContent, metadata: additionalMetadata } = parsedData
return new Document({
pageContent,
metadata:
parsed.length === 1
? { ...metadata, ...additionalMetadata }
: {
...metadata,
line: i + 1,
...additionalMetadata
}
})
})
}
View on GitHub (pinned to abe4a8601a)
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.
Example fix
// before - pointer '/count' is numeric in some lines new JSONLinesLoader(file, '/count') // after - target the text field new JSONLinesLoader(file, '/message')
Defensive patterns
Strategy: type-guard
Validate before calling
// Validate every line of the JSONL resolves to a string at the pointer
function validateJsonlPointers(text, pointer) {
const jp = require('jsonpointer')
const lines = text.split(/\r?\n/).filter(Boolean)
lines.forEach((line, i) => {
const rec = JSON.parse(line)
const v = pointer ? jp.get(rec, pointer) : rec
if (typeof v !== 'string') throw new Error(`line ${i + 1}: pointer '${pointer}' is ${typeof v}, not string`)
})
} Type guard
function isStringRecord(value) { return typeof value === 'string' } Try / catch
try {
return await jsonLinesLoader.load()
} catch (e) {
if (/Expected string, at position/.test(e.message)) {
throw new Error('JSONL target field is not a string on some line — check pointer', { cause: e })
}
throw e
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Streaming logs where the 'message' field is sometimes a string and sometimes an object; pointing at a numeric metric field; mixed-schema JSONL exports.
Related errors
- Expected string, at position ${i} got ${typeof pageContent}
- Invalid JSON in the Chat NVIDIA NIM's baseOptions: ${excepti
- Invalid JSON in the ChatOpenAI's BaseOptions: ${exception}
- Invalid JSON in the ChatOpenAI's BaseOptions: ${exception}
- Invalid JSON in the ChatOpenRouter's BaseOptions: ${exceptio
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/d907f6131d332a41.
Report an issue: GitHub.