{"record":{"id":"86a0214323e3304d","repo":"mastra-ai/mastra","slug":"extractor-name-is-required","errorCode":null,"errorMessage":"Extractor name is required.","messagePattern":"Extractor name is required\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/extractor.ts","lineNumber":146,"sourceCode":"  readonly schema: z.ZodType<T>;\n  readonly mode: ExtractorMode;\n  readonly includePreviousExtraction: boolean;\n  readonly metadataKeyPath: string | false;\n  readonly onExtracted?: ExtractorConfig<T>['onExtracted'];\n  readonly retryStructuredExtractionOnEmptyObject: boolean;\n  /** @internal */\n  readonly internal: boolean;\n  private readonly instructionsConfig: ExtractorConfigValue<string>;\n  private readonly schemaConfig?: ExtractorConfigValue<z.ZodType<T> | undefined>;\n\n  constructor(config: ExtractorConfig<T>, internal = false) {\n    const name = config.name.trim();\n    const instructions = typeof config.instructions === 'string' ? config.instructions.trim() : undefined;\n    const slug = slugifyExtractorName(name);\n    const isHook = config.mode === 'hook';\n\n    if (!name) {\n      throw new Error('Extractor name is required.');\n    }\n    if (!isHook && !config.instructions) {\n      throw new Error(`Extractor \"${name}\" must include instructions.`);\n    }\n    if (instructions !== undefined && !instructions) {\n      throw new Error(`Extractor \"${name}\" must include instructions.`);\n    }\n    if (isHook && !config.onExtracted) {\n      throw new Error(`Hook extractor \"${name}\" must include an onExtracted handler.`);\n    }\n    if (isHook && (config.instructions || config.schema)) {\n      throw new Error(`Hook extractor \"${name}\" cannot include instructions or a schema.`);\n    }\n    assertValidSlug(slug, name);\n    if (!internal && RESERVED_XML_TAGS.has(slug)) {\n      throw new Error(`Extractor slug \"${slug}\" is reserved by Observational Memory.`);\n    }\n","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/extractor.ts#L128-L164","documentation":"The Extractor constructor trims config.name and requires a non-empty name; extractors are identified by their name/slug throughout observational memory. An empty or whitespace-only name throws immediately.","triggerScenarios":"new Extractor({ name: '' or '   ' , ...}); building extractors from external config where name is optional/blank; destructuring a record that lacks a name field.","commonSituations":"Loading extractor definitions from JSON/YAML where a name key was omitted; user-submitted extractor forms submitted with a blank name; mapping over arrays where some items are placeholders.","solutions":["Provide a non-empty, descriptive name when constructing the Extractor","Validate config before construction (skip or fail entries without names)","In form/UI flows, require the name field before creating the extractor"],"exampleFix":"// before\nnew Extractor({ name: config.name ?? '', instructions: '...' });\n\n// after\nif (!config.name?.trim()) throw new Error('Extractor config must include a name');\nnew Extractor({ name: config.name.trim(), instructions: '...' });","handlingStrategy":"validation","validationCode":"const assertNamed = (cfg: ExtractorConfig) => {\n  if (typeof cfg.name !== 'string' || !cfg.name.trim()) {\n    throw new Error('Extractor config.name is required and must be non-empty');\n  }\n};\nassertNamed(config);","typeGuard":"const hasName = (cfg: Partial<ExtractorConfig>): cfg is ExtractorConfig =>\n  typeof cfg.name === 'string' && cfg.name.trim().length > 0;","tryCatchPattern":"try {\n  const extractor = new Extractor(config);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Extractor name is required.') {\n    console.error('Extractor definition missing name:', config);\n  }\n  throw err;\n}","preventionTips":["Make `name` a required field in extractor config schemas (zod/JSON schema with min length 1 after trim)","Validate extractor definitions loaded from files/DB before constructing instances","Require the name field in any UI form that creates extractors"],"tags":["observational-memory","extractor","naming","input-validation"],"backgroundTag":"required-field-missing","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}