{"record":{"id":"4d22b1a604119882","repo":"mastra-ai/mastra","slug":"name-must-be-a-positive-integer-4d22b1","errorCode":null,"errorMessage":"${name} must be a positive integer.","messagePattern":"(.+?) must be a positive integer\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/platform/linear/integration.ts","lineNumber":695,"sourceCode":"  return JSON.stringify(state);\n}\n\nfunction requireLinearConnection(connection: IntegrationConnection): void {\n  if (connection.type !== 'oauth') {\n    throw new Error('Linear capabilities require an OAuth connection.');\n  }\n}\n\nfunction isNotFound(error: unknown): boolean {\n  return error instanceof PlatformApiError && error.status === 404;\n}\n\nfunction optionalPositiveIntegerEnv(name: string): number | undefined {\n  const value = process.env[name]?.trim();\n  if (!value) return undefined;\n  const parsed = Number(value);\n  if (!Number.isSafeInteger(parsed) || parsed <= 0) {\n    throw new Error(`${name} must be a positive integer.`);\n  }\n  return parsed;\n}\n","sourceCodeStart":677,"sourceCodeEnd":699,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/platform/linear/integration.ts#L677-L699","documentation":"`optionalPositiveIntegerEnv` reads a numeric tuning option from an environment variable and throws `${name} must be a positive integer.` when the variable is set (non-empty after trim) but does not parse to a safe positive integer. 'Optional' means absent/blank is fine (returns undefined), but a present value must be valid — the library fails fast rather than silently clamping.","triggerScenarios":"Setting a tuning env var (any name read via this helper at integration.ts:695) to '0', '-5', '3.5', 'abc', or a value beyond Number.MAX_SAFE_INTEGER, then constructing the Linear integration.","commonSituations":"Ops setting `SOME_VAR=0` to disable a feature; locale-formatted numbers ('1,000'); decimal milliseconds ('1500.5'); unit confusion (seconds written where milliseconds expected, e.g. '30' vs '30000' is fine but '0.03' is not).","solutions":["Set the env var to a positive integer string, e.g. `SOME_VAR=30000`.","Unset the variable entirely (or leave it blank) to use the library default.","Fix non-integer forms: remove decimals, commas, units, and negative signs.","In deployment config, add a regex check `^\\d+$` on these vars before deploy."],"exampleFix":"// before (env)\nLINEAR_PAGE_SIZE=0\n// after (env)\nLINEAR_PAGE_SIZE=100  # or unset the variable to use the default","handlingStrategy":"validation","validationCode":"function readPositiveIntEnv(name: string): number | undefined {\n  const v = process.env[name]?.trim();\n  if (!v) return undefined;\n  const n = Number(v);\n  if (!Number.isSafeInteger(n) || n <= 0) {\n    throw new Error(`${name} must be a positive integer (got \"${v}\")`);\n  }\n  return n;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate all tuning env vars at deploy time with a `^\\d+$` regex check.","Leave optional numeric env vars unset rather than setting them to 0.","Avoid locale formatting (commas, decimals, units) in numeric env values."],"tags":["environment","configuration","validation","linear"],"backgroundTag":"invalid-env-var","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}