{"record":{"id":"9425f436eb59eb89","repo":"mastra-ai/mastra","slug":"invalid-parameters-for-strategy-strategy-ke","errorCode":null,"errorMessage":"Invalid parameters for ${strategy} strategy: '${keys}' not supported","messagePattern":"Invalid parameters for (.+?) strategy: '(.+?)' not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/rag/src/document/validation.ts","lineNumber":134,"sourceCode":"  'semantic-markdown': semanticMarkdownChunkOptionsSchema,\n  latex: latexChunkOptionsSchema,\n} as const;\n\nexport function validateChunkParams(strategy: ChunkStrategy, params: any): void {\n  const schema = validationSchemas[strategy];\n  if (!schema) {\n    throw new Error(`Unknown chunking strategy: ${strategy}`);\n  }\n\n  const result = schema.safeParse(params);\n  if (!result.success) {\n    // Extract unrecognized keys for cleaner error message\n    // Use 'issues' for Zod v4 compatibility (also available in Zod v3)\n    const issues = result.error.issues;\n    const unrecognizedError = issues.find((e: any) => e.code === 'unrecognized_keys');\n    if (unrecognizedError && 'keys' in unrecognizedError) {\n      const keys = (unrecognizedError as any).keys.join(', ');\n      throw new Error(`Invalid parameters for ${strategy} strategy: '${keys}' not supported`);\n    }\n\n    // Fallback to general error message for other validation issues\n    const errorMessage = issues\n      .map((e: any) => `${e.path.length > 0 ? e.path.join('.') : 'parameter'}: ${e.message}`)\n      .join(', ');\n\n    throw new Error(`Invalid parameters for ${strategy} strategy: ${errorMessage}`);\n  }\n}\n","sourceCodeStart":116,"sourceCodeEnd":145,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/rag/src/document/validation.ts#L116-L145","documentation":"When the Zod schema for the chosen strategy rejects the params, validateChunkParams inspects the issues for an 'unrecognized_keys' code. If found, it throws this error naming exactly which keys are not supported for that strategy. It surfaces typos or options belonging to a different chunking strategy.","triggerScenarios":"Passing options not in the strategy's schema, e.g. { strategy: 'character', params: { separator: '\\n\\n', encodingName: 'cl100k_base' } } — encodingName belongs to token chunking; or passing 'model'/'modelName' to character chunking; or misspelled keys like 'maxsize'.","commonSituations":"Reusing one params object for multiple strategies; mixing LangChain option names (chunkSize vs maxSize); adding tiktoken options to non-token strategies; IDE autocompleting from the wrong union member.","solutions":["Remove the keys listed in the error message; they are not part of this strategy's schema.","Move strategy-specific keys to the correct strategy (e.g. encodingName/modelName belong to token-based chunking).","Check the exported options type for the strategy to see the exact allowed keys.","If the key is genuinely needed, it means you want a different strategy — switch strategy rather than forcing the option."],"exampleFix":"// before\nawait chunk(docs, { strategy: 'sentence', params: { maxSize: 500, overlap: 100, encodingName: 'cl100k_base' } });\n// after\nawait chunk(docs, { strategy: 'sentence', params: { maxSize: 500, overlap: 100 } });","handlingStrategy":"validation","validationCode":"const allowed = new Set(['maxSize','overlap','separator','separatorPosition','lengthFunction','addStartIndex','stripWhitespace']);\nconst extra = Object.keys(params).filter(k => !allowed.has(k));\nif (extra.length) throw new Error(`Unsupported keys for this strategy: ${extra.join(', ')}`);","typeGuard":null,"tryCatchPattern":"try {\n  await chunk(docs, { strategy, params });\n} catch (e) {\n  if ((e as Error).message.includes('not supported')) {\n    console.error('Remove or relocate the listed keys; they belong to another strategy');\n  }\n  throw e;\n}","preventionTips":["Use strategy-specific typed option objects so excess keys are compile errors.","Don't share one params object across strategies; build per-strategy configs.","Keep tiktoken options (encodingName, modelName) only in token strategies.","Match mastra option names (maxSize/overlap), not other libraries' (chunkSize/chunkOverlap)."],"tags":["rag","chunking","validation","zod","configuration"],"backgroundTag":"schema-validation-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}