{"record":{"id":"d31c6872dbb9c4e7","repo":"n8n-io/n8n","slug":"error-no-json-string-provided","errorCode":null,"errorMessage":"Error: No JSON string provided.","messagePattern":"Error: No JSON string provided\\.","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.ts","lineNumber":256,"sourceCode":"export function getFilterValue<T>(\n\tname: string,\n\tcontext: IExecuteFunctions | ISupplyDataFunctions,\n\titemIndex: number,\n): T | undefined {\n\tconst options: IDataObject = context.getNodeParameter('options', itemIndex, {});\n\n\tif (options[name]) {\n\t\tif (typeof options[name] === 'string') {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(options[name]);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${error.message}`, {\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription: `Could not parse JSON for ${name}`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthrow new NodeOperationError(context.getNode(), 'Error: No JSON string provided.', {\n\t\t\titemIndex,\n\t\t\tdescription: `Could not parse JSON for ${name}`,\n\t\t});\n\t}\n\n\treturn undefined;\n}\n\nclass ExtendedMongoDBAtlasVectorSearch extends MongoDBAtlasVectorSearch {\n\tmongoClient: MongoClient;\n\tpreFilter: IDataObject;\n\tpostFilterPipeline?: IDataObject[];\n\n\tconstructor(\n\t\tembeddings: EmbeddingsInterface,\n\t\toptions: MongoDBAtlasVectorSearchLibArgs,\n\t\tmongoClient: MongoClient,\n\t\tpreFilter: IDataObject,","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.ts#L238-L274","documentation":"NodeOperationError thrown by `getFilterValue` when the option `name` is truthy but its value is not a string. The handler only attempts `JSON.parse` on strings, so any other type (number, object, array) — which the UI should not produce but expressions can — lands here.","triggerScenarios":"An expression bound to the pre/post filter option returns an object directly (e.g. `={{ $json.filter }}` where `filter` is already an object) instead of a JSON string; the option value was injected programmatically as a non-string.","commonSituations":"User passes an already-parsed object via expression and skips the JSON-string step the field expects; programmatic workflow injection setting the option to an object; typeVersion drift leaving the option as a non-string.","solutions":["If the value is already an object, pass it through `JSON.stringify` first or restructure to bypass the option field.","Set the option field to a JSON string literal (e.g. `{ \"category\": \"books\" }`).","Use an expression that returns a string: `={{ JSON.stringify($json.filter) }}`."],"exampleFix":"// before\nif (typeof options[name] === 'string') {\n  // ... JSON.parse ...\n}\nthrow new NodeOperationError(context.getNode(), 'Error: No JSON string provided.', {\n  itemIndex,\n  description: `Could not parse JSON for ${name}`,\n});\n\n// after: accept already-parsed objects instead of rejecting them\nif (typeof options[name] === 'string') {\n  try { return JSON.parse(options[name]); } catch (error) { /* ... */ }\n}\nif (options[name] && typeof options[name] === 'object') {\n  return options[name];\n}\nthrow new NodeOperationError(context.getNode(), `Expected a JSON string for ${name}`, { itemIndex });","handlingStrategy":"type-guard","validationCode":"// Accept either a JSON string or an already-parsed object.\nfunction resolveFilterValue<T>(value: unknown, name: string, itemIndex: number): T | undefined {\n  if (!value) return undefined;\n  if (typeof value === 'string') {\n    try { return JSON.parse(value) as T; }\n    catch (error) { throw new NodeOperationError(/* ... */); }\n  }\n  if (typeof value === 'object') return value as T;\n  throw new NodeOperationError(/* 'Expected JSON string or object' */);\n}","typeGuard":"function isJsonable(value: unknown): value is string | object {\n  return typeof value === 'string' || (typeof value === 'object' && value !== null);\n}","tryCatchPattern":"// No external try/catch needed; this is a synchronous shape check.\nif (options[name] && typeof options[name] !== 'string' && typeof options[name] === 'object') {\n  return options[name];\n}\nif (typeof options[name] === 'string') { /* JSON.parse path */ }\nthrow new NodeOperationError(context.getNode(), `Expected a JSON string for ${name}`, { itemIndex });","preventionTips":["Pass already-parsed objects via expressions and adjust the helper to accept them.","Document that the field accepts strict JSON strings only by default.","Add a unit test covering string, object, and missing inputs."],"tags":["mongodb-atlas","vector-store","type-validation","filter","node-operation-error","langchain"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}