{"record":{"id":"bf3047b0cc4b0ff2","repo":"FlowiseAI/Flowise","slug":"expected-string-at-position-i-got-typeof-pag","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/Json/Json.ts","lineNumber":286,"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":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/Json/Json.ts#L268-L304","documentation":"Thrown by JSONTextLoader.load (Json.ts) during a type check on each parsed document: the loader expects every parsed pageContent to be a string. It fires when the JSON pointer resolves a field whose value is a number, boolean, array, object, or null rather than text.","triggerScenarios":"A JSON pointer like '/price' resolves to a numeric field; '/tags' resolves to an array; the pointer is empty so the whole record becomes pageContent (an object); the source JSON has null where a string was expected.","commonSituations":"User points the loader at a numeric/boolean JSON field by mistake; a JSONL feed mixes schemas where some records have a string 'text' and others have an object; the pointer is omitted for a JSON array of non-string scalars.","solutions":["Inspect the JSON at the failing index i — the field the pointer targets is not a string.","Point the pointer at a string-valued field (e.g. '/body' or '/description') instead of '/id' or '/count'.","If you want non-string scalars as text, coerce them in a pre-processing step or pick a pointer to a string field.","If records are heterogeneous, filter or normalize the JSON before loading."],"exampleFix":"// before: pointer '/price' resolves to a number\nnew JSONLoader(file, '/price')\n// after: point at a text field, or stringify scalars\nnew JSONLoader(file, '/description')\n// or coerce in the source data:\n// data.forEach(r => { r.text = String(r.price) })","handlingStrategy":"type-guard","validationCode":"// Walk the JSON at the pointer and ensure every resolution is a string\nfunction pointerValuesAreStrings(json, pointer) {\n  const records = Array.isArray(json) ? json : [json]\n  return records.every((rec, i) => {\n    const v = pointer ? require('jsonpointer').get(rec, pointer) : rec.text\n    return typeof v === 'string'\n  })\n}","typeGuard":"function isStringPageContent(parsed) {\n  return parsed.every((p, i) => typeof p.pageContent === 'string')\n}","tryCatchPattern":"try {\n  return await jsonLoader.load()\n} catch (e) {\n  if (/Expected string, at position (\\d+) got (\\w+)/.test(e.message)) {\n    const [, idx, type] = e.message.match(/position (\\d+) got (\\w+)/)\n    throw new Error(`JSON field at record ${idx} is ${type}, not a string — fix the pointer`, { cause: e })\n  }\n  throw e\n}","preventionTips":["Point the JSON pointer at a guaranteed string field.","Pre-scan the JSON to confirm the target field is always a string.","Normalize non-string scalars to strings upstream.","For mixed schemas, filter or coerce records before loading."],"tags":["json","type-check","jsonpointer","validation"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}