{"record":{"id":"934527fe074a8604","repo":"mastra-ai/mastra","slug":"invalid-subconscious-record-time-value","errorCode":null,"errorMessage":"Invalid Subconscious record time: ${value}","messagePattern":"Invalid Subconscious record time: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/memory/src/processors/observational-memory/subconscious/capture.ts","lineNumber":106,"sourceCode":"  }\n  return [`org:${organizationId}`, `resource:${resourceId}`, `thread:${context.threadId}`];\n}\n\nasync function getKnowledgeStore(context: ExtractorRuntimeContext): Promise<KnowledgeStorage> {\n  if (!context.memory) throw new Error('Subconscious capture requires an active Memory instance.');\n  const store = await context.memory.storage.getStore('knowledge');\n  if (!store) {\n    throw new Error(\n      'Subconscious requires a knowledge storage domain. Configure a storage adapter that provides stores.knowledge.',\n    );\n  }\n  return store;\n}\n\nfunction parseWhen(value: string | undefined): Date | undefined {\n  if (!value) return undefined;\n  const when = new Date(value);\n  if (Number.isNaN(when.getTime())) throw new Error(`Invalid Subconscious record time: ${value}`);\n  return when;\n}\n\nexport interface CaptureExtractorOptions {\n  config?: SubconsciousCaptureConfig;\n  defaultScope: KnowledgeScopeLevel;\n  maxScope?: KnowledgeScopeLevel;\n  learnedGuidance: boolean;\n  activityRecentUpdates?: number;\n  /** Resolved pins config; capture-time pinning activates only when `capturePinning` is true. */\n  pins?: false | { maxPins: number; maxCharacters: number; capturePinning: boolean };\n}\n\nexport class SubconsciousCaptureExtractor extends Extractor<SubconsciousCaptureOutput> {\n  constructor(options: CaptureExtractorOptions) {\n    const capturePinning = options.pins !== false && options.pins !== undefined && options.pins.capturePinning;\n    // Dropped-pin notes per extraction call, surfaced through the activity publish.\n    // Keyed on the extraction OUTPUT (context.current): a custom onExtracted hook","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/subconscious/capture.ts#L88-L124","documentation":"parseWhen converts a model-provided 'when' string into a Date for Subconscious record timestamps. If the value is non-empty but unparseable (NaN time), it throws rather than silently storing an invalid date.","triggerScenarios":"The extractor/LLM emitted a malformed timestamp for a knowledge record's `when` field — e.g. 'yesterday', '2024-13-45', or partial dates — which new Date() fails to parse.","commonSituations":"Weak models producing natural-language dates; prompt templates not enforcing ISO-8601; locale-formatted dates in LLM output.","solutions":["Tighten the Subconscious capture prompt/schema to require ISO-8601 (e.g. '2026-08-29T12:00:00Z')","Pre-sanitize model output: normalize or drop invalid `when` values before capture","Use a stronger model for extraction if malformed dates persist"],"exampleFix":"// before\n// LLM output: when: \"last Tuesday\"\n// after — enforce ISO in prompt/schema\nschema: z.object({ when: z.string().datetime().optional() })","handlingStrategy":"validation","validationCode":"const d = new Date(value); if (value && Number.isNaN(d.getTime())) return undefined; // or normalize","typeGuard":"const isParseableDate = (v?: string): v is string => !!v && !Number.isNaN(new Date(v).getTime());","tryCatchPattern":"try { rec = await capture(params) } catch (e) { if (String(e).includes('Invalid Subconscious record time')) { sanitizeDatesAndRetry(); } else throw e; }","preventionTips":["Constrain extractor schemas to ISO-8601 datetime strings","Validate/normalize LLM date output before persistence","Prefer models with strong structured-output support"],"tags":["llm","validation","date-parsing","subconscious"],"backgroundTag":"invalid-date-format","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}