{"record":{"id":"b702e6b88b853f23","repo":"mastra-ai/mastra","slug":"linearintegration-is-missing-required-config-mi","errorCode":null,"errorMessage":"LinearIntegration is missing required config: ${missing.join(', ')}.","messagePattern":"LinearIntegration is missing required config: (.+?)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/linear/integration.ts","lineNumber":580,"sourceCode":"    if (externalSource.type !== 'issue') return null;\n    const connection = await this.loadConnection(orgId);\n    if (!connection) return null;\n    const accessToken = await this.getFreshAccessToken(connection);\n    return { connection: { type: 'oauth', accessToken }, issueId: externalSource.externalId };\n  }\n  /**\n   * The OAuth connect/callback flow round-trips a signed `state` through\n   * Linear, so a multi-replica deploy needs a deployment-stable state secret.\n   */\n  readonly requiresStableStateSigner = true;\n\n  readonly #clientId: string;\n  readonly #clientSecret: string;\n\n  constructor(config: LinearIntegrationConfig) {\n    const missing = (['clientId', 'clientSecret'] as const).filter(key => !config[key]);\n    if (missing.length > 0) {\n      throw new Error(`LinearIntegration is missing required config: ${missing.join(', ')}.`);\n    }\n    this.#clientId = config.clientId;\n    this.#clientSecret = config.clientSecret;\n  }\n\n  // ── OAuth ────────────────────────────────────────────────────────────────\n\n  /**\n   * Build the OAuth authorize URL. `prompt=consent` forces the workspace\n   * picker even for an already-authorized user, so \"reconnect\" can switch\n   * workspaces.\n   */\n  buildAuthorizeUrl(state: string, redirectUri: string): string {\n    const url = new URL(LINEAR_AUTHORIZE_URL);\n    url.searchParams.set('client_id', this.#clientId);\n    url.searchParams.set('redirect_uri', redirectUri);\n    url.searchParams.set('response_type', 'code');\n    // `comments:create` lets the agent's linear_create_comment tool post","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/linear/integration.ts#L562-L598","documentation":"The `LinearIntegration` constructor validates its config synchronously and throws when any of the required keys `clientId` or `clientSecret` is missing or falsy, listing the missing keys. These credentials come from your Linear OAuth application and are needed to build authorize URLs and exchange/refresh tokens.","triggerScenarios":"Calling `new LinearIntegration({ clientId: '', clientSecret })` (or vice versa) — typically because environment variables (e.g. LINEAR_CLIENT_ID / LINEAR_CLIENT_SECRET) are unset or empty at bootstrap, so `process.env.X ?? ''` yields an empty string.","commonSituations":"Missing `.env` entries in local dev; deploy environments where the secrets were never configured; typos in env var names; conditional config objects built with spread where the key ends up undefined; reading from a config loader that drops empty strings.","solutions":["Set both `clientId` and `clientSecret` from your Linear OAuth application settings and pass them to the constructor.","Check the message — it names exactly which keys are missing.","Verify the env vars are present in the deploy environment (e.g. `printenv | grep LINEAR`) and loaded before bootstrap.","Fail fast at startup: constructing the integration throws immediately, so let the process crash with this message rather than deferring."],"exampleFix":"// before (env may be undefined)\nnew LinearIntegration({ clientId: process.env.LINEAR_CLIENT_ID ?? '', clientSecret: process.env.LINEAR_CLIENT_SECRET ?? '' });\n// after\nconst clientId = process.env.LINEAR_CLIENT_ID;\nconst clientSecret = process.env.LINEAR_CLIENT_SECRET;\nif (!clientId || !clientSecret) throw new Error('Set LINEAR_CLIENT_ID and LINEAR_CLIENT_SECRET');\nnew LinearIntegration({ clientId, clientSecret });","handlingStrategy":"validation","validationCode":"const clientId = process.env.LINEAR_CLIENT_ID;\nconst clientSecret = process.env.LINEAR_CLIENT_SECRET;\nif (!clientId) throw new Error('LINEAR_CLIENT_ID is required');\nif (!clientSecret) throw new Error('LINEAR_CLIENT_SECRET is required');\nconst integration = new LinearIntegration({ clientId, clientSecret });","typeGuard":"function hasLinearConfig(c: unknown): c is { clientId: string; clientSecret: string } {\n  const o = c as Record<string, unknown>;\n  return typeof o.clientId === 'string' && o.clientId.length > 0 && typeof o.clientSecret === 'string' && o.clientSecret.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Validate env vars at process startup before constructing integrations.","Add both LINEAR_CLIENT_ID and LINEAR_CLIENT_SECRET to .env.example and deploy secrets.","Prefer explicit throwing over `?? ''` defaults so misconfiguration is obvious.","Check the error message — it lists exactly which keys were missing."],"tags":["configuration","oauth","env-var","startup"],"backgroundTag":"missing-env-var","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}