mastra-ai/mastra · error
A multi-line review comment requires both startLine and star
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).
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)
Solutions
- Supply both startLine and startSide together when creating multi-line comments
- Set neither field for single-line comments
- 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
- Group startLine/startSide into a single optional range object in your input types
- Toggle both fields together in comment-form UI state
- Add a shared validator used by every code path that builds review-comment payloads
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 field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- GitHub pull requests require an owner/repository source.
- A review comment requires commitId, path, line, and side unl
- GitHub triage comments require an owner/repository source.
- GitHub ${resource} id must be a positive integer.
- ${message}
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/f52bdc47718ffc92.
Report an issue: GitHub.