{"record":{"id":"bf00f4511ed2c67c","repo":"mastra-ai/mastra","slug":"subconscious-pins-maxpins-must-be-a-positive-integ","errorCode":null,"errorMessage":"Subconscious pins.maxPins must be a positive integer.","messagePattern":"Subconscious pins\\.maxPins must be a positive integer\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/subconscious/index.ts","lineNumber":119,"sourceCode":"    if (\n      recentUpdates !== false &&\n      (!Number.isInteger(recentUpdates) || recentUpdates < 1 || recentUpdates > MAX_RECENT_UPDATES)\n    ) {\n      throw new Error(`Subconscious activity.recentUpdates must be an integer between 1 and ${MAX_RECENT_UPDATES}.`);\n    }\n\n    const pins =\n      config.pins === undefined || config.pins === false\n        ? false\n        : {\n            maxPins: (config.pins === true ? undefined : config.pins.maxPins) ?? DEFAULT_MAX_PINS,\n            maxCharacters:\n              (config.pins === true ? undefined : config.pins.maxCharacters) ?? DEFAULT_PINNED_MAX_CHARACTERS,\n            capturePinning: (config.pins === true ? undefined : config.pins.capturePinning) ?? false,\n          };\n    if (pins !== false) {\n      if (!Number.isInteger(pins.maxPins) || pins.maxPins < 1) {\n        throw new Error('Subconscious pins.maxPins must be a positive integer.');\n      }\n      if (\n        !Number.isInteger(pins.maxCharacters) ||\n        pins.maxCharacters < 1 ||\n        pins.maxCharacters > MAX_PINNED_MAX_CHARACTERS\n      ) {\n        throw new Error(\n          `Subconscious pins.maxCharacters must be an integer between 1 and ${MAX_PINNED_MAX_CHARACTERS}.`,\n        );\n      }\n    }\n\n    if (\n      config.curationCadence !== undefined &&\n      (!Number.isInteger(config.curationCadence) || config.curationCadence < 1)\n    ) {\n      throw new Error('Subconscious curationCadence must be a positive integer.');\n    }","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/subconscious/index.ts#L101-L137","documentation":"When pins are enabled in Subconscious config, pins.maxPins must be a positive integer (>= 1). Pins are stored per scope, and a non-positive or non-integer maxPins makes the pin store incoherent, so the constructor throws. Note maxPins has no default override here — it must be valid whenever pins !== false.","triggerScenarios":"Configuring pins: { maxPins: 0 }, maxPins: -1, a float, or omitting maxPins while pins is an object and the resolved default is somehow invalid; passing a string value from parsed config.","commonSituations":"Disabling pins with pins: {} instead of pins: false (making the maxPins check run); env-sourced config producing strings; arithmetic on maxPins yielding 0 (e.g. Math.floor of a small fraction).","solutions":["Set pins.maxPins to a positive integer (e.g. 10).","Use pins: false (not an empty object) to disable pinning entirely.","Coerce/validate config values with Number.isInteger before constructing."],"exampleFix":"// before\nnew Subconscious({ pins: { maxPins: 0 } })\n// after\nnew Subconscious({ pins: { maxPins: 20 } })","handlingStrategy":"validation","validationCode":"if (config.pins && config.pins !== true) {\n  const mp = config.pins.maxPins;\n  if (!Number.isInteger(mp) || mp < 1) throw new Error('pins.maxPins must be a positive integer');\n}","typeGuard":"function isValidPinsConfig(p: unknown): p is { maxPins: number; maxCharacters?: number } {\n  return typeof p === 'object' && p !== null && Number.isInteger((p as { maxPins?: unknown }).maxPins) && (p as { maxPins: number }).maxPins >= 1;\n}","tryCatchPattern":"try {\n  const sub = new Subconscious(config);\n} catch (err) {\n  if (err.message.includes('pins.maxPins')) {\n    throw new ConfigError('Set pins.maxPins to a positive integer, or use pins: false to disable');\n  } else throw err;\n}","preventionTips":["Use pins: false (not pins: {}) to disable pinning.","Coerce env-sourced numbers with Number() before constructing.","Validate pins config with a zod schema requiring positive integers."],"tags":["configuration","validation","subconscious"],"backgroundTag":"range-validation-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}