mastra-ai/mastra · error

A multi-line review comment requires both startLine and…

Error message

A multi-line review comment requires both startLine and startSide.

What it means

GitHub multi-line review comments require both startLine and startSide; the integration enforces that they are either both present or both absent, throwing on the asymmetric case (XOR of the two being undefined).

Solutions

  1. Supply both startLine and startSide together when creating multi-line comments
  2. Set neither field for single-line comments
  3. Validate the pair (both-or-neither) at the caller before invoking the integration

Example fix

// before
await gh.createReviewComment({ ..., commitId, path, line: 50, side: 'RIGHT', startLine: 45 }); // startSide missing
// after
await gh.createReviewComment({ ..., commitId, path, line: 50, side: 'RIGHT', startLine: 45, startSide: 'RIGHT' });
Defensive patterns

Strategy: validation

Validate before calling

if ((input.startLine === undefined) !== (input.startSide === undefined)) {
  throw new Error('multi-line review comment requires both startLine and startSide (or neither)');
}

Try / catch

try {
  await gh.createReviewComment(input);
} catch (e) {
  if (e.message.startsWith('A multi-line review comment requires both startLine')) {
    // add the missing startSide/startLine or drop both for a single-line comment
  } else throw e;
}

Prevention

When it happens

Trigger: Creating a review comment where startLine is set but startSide is undefined (or vice versa) — the API payload would be rejected by GitHub as incomplete range specification.

Common situations: UIs that let users pick an end line but forget the range start side; code that copies startLine from one comment template but not startSide; SIDE differences when spanning LEFT/RIGHT sides of a diff.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at mastracode/factory/src/integrations/github/integration.ts:944

  }

  async #createReviewComment(input: InputOf<'createReviewComment'>) {
    const { octokit, parts } = this.#repositoryClient(input.connection, input.sourceId);
    const pullNumber = requirePullRequestNumber(input.pullRequestId);
    if (input.replyToId) {
      const { data } = await octokit.pulls.createReplyForReviewComment({
        ...parts,
        pull_number: pullNumber,
        comment_id: requirePositiveId(input.replyToId, 'review comment'),
        body: input.body,
      });
      return parseReviewComment(data);
    }
    if (!input.commitId || !input.path || input.line === undefined || !input.side) {
      throw new Error('A review comment requires commitId, path, line, and side unless it is a reply.');
    }
    if ((input.startLine === undefined) !== (input.startSide === undefined)) {
      throw new Error('A multi-line review comment requires both startLine and startSide.');
    }
    const { data } = await octokit.pulls.createReviewComment({
      ...parts,
      pull_number: pullNumber,
      body: input.body,
      commit_id: input.commitId,
      path: input.path,
      line: input.line,
      side: input.side.toUpperCase() as 'LEFT' | 'RIGHT',
      start_line: input.startLine,
      start_side: input.startSide?.toUpperCase() as 'LEFT' | 'RIGHT' | undefined,
    });
    return parseReviewComment(data);
  }

  async #updateReviewComment(input: InputOf<'updateReviewComment'>) {
    const { octokit, parts } = this.#repositoryClient(input.connection, input.sourceId);
    const { data } = await octokit.pulls.updateReviewComment({

View on GitHub (pinned to 75dd419e61)