mastra-ai/mastra · error

Linear did not accept the comment.

Error message

Linear did not accept the comment.

What it means

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.

Source

Thrown at mastracode/factory/src/integrations/linear/integration.ts:969

        accessToken,
        `query IssueId($id: String!) { issue(id: $id) { id } }`,
        { id: idOrIdentifier },
      );
      if (!data.issue) return null;
      issueId = data.issue.id;
    } catch (err) {
      if (err instanceof Error && /entity not found/i.test(err.message)) return null;
      throw err;
    }
    const data = await linearGraphql<CommentCreateMutationData>(
      accessToken,
      `mutation CommentCreate($input: CommentCreateInput!) {
        commentCreate(input: $input) { success comment { id url } }
      }`,
      { input: { issueId, body } },
    );
    if (!data.commentCreate.success || !data.commentCreate.comment) {
      throw new Error('Linear did not accept the comment.');
    }
    return data.commentCreate.comment;
  }

  // ── FactoryIntegration surface ───────────────────────────────────────────

  workers(ctx: IntegrationContext): MastraWorker[] {
    if (!linearIssueReconciliationEnabled()) return [];
    const reconcile = attachLinearIssueReconciler(this, ctx);
    if (!reconcile) return [];
    const intervalMs = linearIssueReconciliationInterval();
    return [
      new IssueReconcileWorker({
        integrationId: this.id,
        reconcile,
        ...(intervalMs ? { intervalMs } : {}),
      }),
    ];

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Verify the `issueId` is current by fetching the issue detail immediately before posting the comment.
  2. Check the Linear OAuth token has write scope for comments.
  3. Ensure `body` is non-empty and within Linear's content limits.
  4. Log the raw GraphQL response (errors/userErrors) for the precise rejection reason.
  5. Retry once with a re-resolved issue id after a short backoff.

Example fix

// before
if (!data.commentCreate.success || !data.commentCreate.comment) {
  throw new Error('Linear did not accept the comment.');
}
// after
if (!data.commentCreate.success || !data.commentCreate.comment) {
  const fresh = await this.fetchIssueDetail(accessToken, issueId);
  if (!fresh) throw new Error(`Cannot comment: issue ${issueId} no longer exists in Linear.`);
  throw new Error(`Linear did not accept the comment on issue ${issueId}; check token scope and body content.`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

const issue = await getLinearIssue(accessToken, issueId);
if (!issue) throw new Error(`Refusing to comment: issue ${issueId} does not exist.`);
if (!body?.trim()) throw new Error('Refusing to comment: body is empty.');

Type guard

function hasCommentPayload(r: { commentCreate?: { success?: boolean; comment?: { id: string; url: string } | null } | null }): r is { commentCreate: { success: true; comment: { id: string; url: string } } } {
  return !!r?.commentCreate?.success && !!r?.commentCreate?.comment;
}

Try / catch

try {
  await integration.addComment(issueId, body);
} catch (e) {
  if (e.message === 'Linear did not accept the comment.') {
    const exists = await integration.fetchIssueDetail(issueId);
    if (!exists) console.warn(`Issue ${issueId} gone; skipping comment.`);
    else throw new Error(`Comment rejected for live issue ${issueId}: check token scope/body.`, { cause: e });
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/d72087d810eca4fd. Report an issue: GitHub.