{"record":{"id":"d72087d810eca4fd","repo":"mastra-ai/mastra","slug":"linear-did-not-accept-the-comment","errorCode":null,"errorMessage":"Linear did not accept the comment.","messagePattern":"Linear did not accept the comment\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/linear/integration.ts","lineNumber":969,"sourceCode":"        accessToken,\n        `query IssueId($id: String!) { issue(id: $id) { id } }`,\n        { id: idOrIdentifier },\n      );\n      if (!data.issue) return null;\n      issueId = data.issue.id;\n    } catch (err) {\n      if (err instanceof Error && /entity not found/i.test(err.message)) return null;\n      throw err;\n    }\n    const data = await linearGraphql<CommentCreateMutationData>(\n      accessToken,\n      `mutation CommentCreate($input: CommentCreateInput!) {\n        commentCreate(input: $input) { success comment { id url } }\n      }`,\n      { input: { issueId, body } },\n    );\n    if (!data.commentCreate.success || !data.commentCreate.comment) {\n      throw new Error('Linear did not accept the comment.');\n    }\n    return data.commentCreate.comment;\n  }\n\n  // ── FactoryIntegration surface ───────────────────────────────────────────\n\n  workers(ctx: IntegrationContext): MastraWorker[] {\n    if (!linearIssueReconciliationEnabled()) return [];\n    const reconcile = attachLinearIssueReconciler(this, ctx);\n    if (!reconcile) return [];\n    const intervalMs = linearIssueReconciliationInterval();\n    return [\n      new IssueReconcileWorker({\n        integrationId: this.id,\n        reconcile,\n        ...(intervalMs ? { intervalMs } : {}),\n      }),\n    ];","sourceCodeStart":951,"sourceCodeEnd":987,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/linear/integration.ts#L951-L987","documentation":"LinearIntegration throws this when Linear's `commentCreate` GraphQL mutation returns `success: false` or no `comment` object, i.e. Linear refused to create the comment even though the request reached the API. The integration requires a valid comment back (id/url), so a missing payload is also treated as failure. The comment was not posted.","triggerScenarios":"Calling the integration's add-comment method (e.g. posting progress/summary comments to an issue) where `commentCreate` responds with no success/comment — typically when `issueId` is invalid or the issue was deleted, the OAuth token lacks comment `write` scope, or `body` is empty/rejected by Linear.","commonSituations":"An automation posts a comment to an issue that was just archived or deleted; the token was regenerated without comment write scope; a stale `issueId` cached from a previous run; comment body exceeds Linear limits or contains content blocked by the workspace.","solutions":["Verify the `issueId` is current by fetching the issue detail immediately before posting the comment.","Check the Linear OAuth token has write scope for comments.","Ensure `body` is non-empty and within Linear's content limits.","Log the raw GraphQL response (errors/userErrors) for the precise rejection reason.","Retry once with a re-resolved issue id after a short backoff."],"exampleFix":"// before\nif (!data.commentCreate.success || !data.commentCreate.comment) {\n  throw new Error('Linear did not accept the comment.');\n}\n// after\nif (!data.commentCreate.success || !data.commentCreate.comment) {\n  const fresh = await this.fetchIssueDetail(accessToken, issueId);\n  if (!fresh) throw new Error(`Cannot comment: issue ${issueId} no longer exists in Linear.`);\n  throw new Error(`Linear did not accept the comment on issue ${issueId}; check token scope and body content.`);\n}","handlingStrategy":"try-catch","validationCode":"const issue = await getLinearIssue(accessToken, issueId);\nif (!issue) throw new Error(`Refusing to comment: issue ${issueId} does not exist.`);\nif (!body?.trim()) throw new Error('Refusing to comment: body is empty.');","typeGuard":"function hasCommentPayload(r: { commentCreate?: { success?: boolean; comment?: { id: string; url: string } | null } | null }): r is { commentCreate: { success: true; comment: { id: string; url: string } } } {\n  return !!r?.commentCreate?.success && !!r?.commentCreate?.comment;\n}","tryCatchPattern":"try {\n  await integration.addComment(issueId, body);\n} catch (e) {\n  if (e.message === 'Linear did not accept the comment.') {\n    const exists = await integration.fetchIssueDetail(issueId);\n    if (!exists) console.warn(`Issue ${issueId} gone; skipping comment.`);\n    else throw new Error(`Comment rejected for live issue ${issueId}: check token scope/body.`, { cause: e });\n  } else throw e;\n}","preventionTips":["Re-fetch the issue immediately before commenting to confirm it exists.","Verify comment write scope on the Linear OAuth token at connect time.","Never post empty or whitespace-only comment bodies.","Keep issueIds from a live query, not long-lived caches.","Capture raw GraphQL errors for the rejection reason."],"tags":["linear","graphql","comment","api-rejected"],"backgroundTag":"linear-api-rejected-mutation","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}