{"record":{"id":"868706c9e57a4da4","repo":"mastra-ai/mastra","slug":"a-review-comment-requires-commitid-path-line-an","errorCode":null,"errorMessage":"A review comment requires commitId, path, line, and side unless it is a reply.","messagePattern":"A review comment requires commitId, path, line, and side unless it is a reply\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/github/integration.ts","lineNumber":941,"sourceCode":"      comments: response.data.map(comment => parseReviewComment(comment)),\n      nextCursor: response.data.length === LIST_PAGE_SIZE ? String(page + 1) : null,\n    };\n  }\n\n  async #createReviewComment(input: InputOf<'createReviewComment'>) {\n    const { octokit, parts } = this.#repositoryClient(input.connection, input.sourceId);\n    const pullNumber = requirePullRequestNumber(input.pullRequestId);\n    if (input.replyToId) {\n      const { data } = await octokit.pulls.createReplyForReviewComment({\n        ...parts,\n        pull_number: pullNumber,\n        comment_id: requirePositiveId(input.replyToId, 'review comment'),\n        body: input.body,\n      });\n      return parseReviewComment(data);\n    }\n    if (!input.commitId || !input.path || input.line === undefined || !input.side) {\n      throw new Error('A review comment requires commitId, path, line, and side unless it is a reply.');\n    }\n    if ((input.startLine === undefined) !== (input.startSide === undefined)) {\n      throw new Error('A multi-line review comment requires both startLine and startSide.');\n    }\n    const { data } = await octokit.pulls.createReviewComment({\n      ...parts,\n      pull_number: pullNumber,\n      body: input.body,\n      commit_id: input.commitId,\n      path: input.path,\n      line: input.line,\n      side: input.side.toUpperCase() as 'LEFT' | 'RIGHT',\n      start_line: input.startLine,\n      start_side: input.startSide?.toUpperCase() as 'LEFT' | 'RIGHT' | undefined,\n    });\n    return parseReviewComment(data);\n  }\n","sourceCodeStart":923,"sourceCodeEnd":959,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/github/integration.ts#L923-L959","documentation":"When creating a pull-request review comment that is not a reply, GitHub's API requires commitId, path, line, and side. The integration validates these fields and throws if any is missing so the request fails locally instead of with an Octokit/GitHub 422.","triggerScenarios":"Calling the create-review-comment operation with replyToId unset and any of commitId, path, line (undefined), or side missing/empty — e.g. commenting on a PR without specifying the file location.","commonSituations":"Building comment UIs that omit side for non-reply comments; forgetting that replies do not need location fields while standalone comments do; schema drift after adding reply support where the non-reply branch was under-populated.","solutions":["Provide commitId (the SHA to comment on), path, line, and side for standalone review comments","If responding to an existing comment, set replyToId instead — location fields are then not required","Validate the comment payload shape before invoking the integration"],"exampleFix":"// before\nawait gh.createReviewComment({ connection, sourceId, pullNumber, body: 'nit', path }); // missing commitId/line/side\n// after\nawait gh.createReviewComment({ connection, sourceId, pullNumber, body: 'nit', commitId: sha, path, line: 42, side: 'RIGHT' });","handlingStrategy":"validation","validationCode":"if (!input.replyToId && (!input.commitId || !input.path || input.line === undefined || !input.side)) {\n  throw new Error('standalone review comment needs commitId, path, line, side');\n}","typeGuard":"function isStandaloneReviewComment(\n  input: ReviewCommentInput,\n): input is ReviewCommentInput & { commitId: string; path: string; line: number; side: 'LEFT' | 'RIGHT' } {\n  return Boolean(input.commitId && input.path && input.line !== undefined && input.side);\n}","tryCatchPattern":"try {\n  await gh.createReviewComment(input);\n} catch (e) {\n  if (e.message.startsWith('A review comment requires commitId')) {\n    // either fill the location fields or switch to a reply via replyToId\n  } else throw e;\n}","preventionTips":["Model two distinct comment variants (reply vs standalone) in your types so the compiler enforces fields","Default side to 'RIGHT' when commenting on new code","Capture the head SHA of the PR as commitId when users comment from the changed-files view"],"tags":["github","validation","input"],"backgroundTag":"missing-required-field","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}