Skip to content

Commit e15181e

Browse files
committed
fix: clarify issue comment update contract
Reject explicitly empty comment bodies at runtime and distinguish issue and pull request conversation comments from pull request review comments in the tool schema and generated docs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9acf9c83-49aa-41af-a42d-ad75de34d132
1 parent 4689e9c commit e15181e

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ The following sets of tools are available:
10601060
- **update_issue_comment** - Update issue comment
10611061
- **OAuth Challenge Scopes**: `repo`
10621062
- `body`: New comment content (string, required)
1063-
- `comment_id`: The numeric ID of the issue or pull request comment to update (integer, required)
1063+
- `comment_id`: The numeric ID of the issue or pull request conversation comment to update. Do not use a pull request review comment ID. (integer, required)
10641064
- `owner`: Repository owner (string, required)
10651065
- `repo`: Repository name (string, required)
10661066

‎pkg/github/__toolsnaps__/update_issue_comment.snap‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"readOnlyHint": false,
55
"title": "Update issue comment"
66
},
7-
"description": "Update the body of an existing issue or pull request comment.",
7+
"description": "Update the body of an existing issue or pull request conversation comment. This tool cannot update pull request review comments.",
88
"inputSchema": {
99
"properties": {
1010
"body": {
@@ -13,7 +13,7 @@
1313
"type": "string"
1414
},
1515
"comment_id": {
16-
"description": "The numeric ID of the issue or pull request comment to update",
16+
"description": "The numeric ID of the issue or pull request conversation comment to update. Do not use a pull request review comment ID.",
1717
"minimum": 1,
1818
"type": "integer"
1919
},

‎pkg/github/issues.go‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,13 +1552,13 @@ func AddIssueComment(t translations.TranslationHelperFunc) inventory.ServerTool
15521552
})
15531553
}
15541554

1555-
// UpdateIssueComment creates a tool to update an issue or pull request comment.
1555+
// UpdateIssueComment creates a tool to update an issue or pull request conversation comment.
15561556
func UpdateIssueComment(t translations.TranslationHelperFunc) inventory.ServerTool {
15571557
return NewTool(
15581558
ToolsetMetadataIssues,
15591559
mcp.Tool{
15601560
Name: "update_issue_comment",
1561-
Description: t("TOOL_UPDATE_ISSUE_COMMENT_DESCRIPTION", "Update the body of an existing issue or pull request comment."),
1561+
Description: t("TOOL_UPDATE_ISSUE_COMMENT_DESCRIPTION", "Update the body of an existing issue or pull request conversation comment. This tool cannot update pull request review comments."),
15621562
Annotations: &mcp.ToolAnnotations{
15631563
Title: t("TOOL_UPDATE_ISSUE_COMMENT_USER_TITLE", "Update issue comment"),
15641564
ReadOnlyHint: false,
@@ -1576,7 +1576,7 @@ func UpdateIssueComment(t translations.TranslationHelperFunc) inventory.ServerTo
15761576
},
15771577
"comment_id": {
15781578
Type: "integer",
1579-
Description: "The numeric ID of the issue or pull request comment to update",
1579+
Description: "The numeric ID of the issue or pull request conversation comment to update. Do not use a pull request review comment ID.",
15801580
Minimum: jsonschema.Ptr(1.0),
15811581
},
15821582
"body": {
@@ -1605,10 +1605,16 @@ func UpdateIssueComment(t translations.TranslationHelperFunc) inventory.ServerTo
16051605
if commentID < 1 {
16061606
return utils.NewToolResultError("comment_id must be greater than 0"), nil, nil
16071607
}
1608-
body, err := RequiredParam[string](args, "body")
1608+
body, hasBody, err := OptionalParamOK[string](args, "body")
16091609
if err != nil {
16101610
return utils.NewToolResultError(err.Error()), nil, nil
16111611
}
1612+
if !hasBody {
1613+
return utils.NewToolResultError("missing required parameter: body"), nil, nil
1614+
}
1615+
if body == "" {
1616+
return utils.NewToolResultError("body cannot be empty when provided"), nil, nil
1617+
}
16121618

16131619
client, err := deps.GetClient(ctx)
16141620
if err != nil {

‎pkg/github/issues_test.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6751,6 +6751,17 @@ func TestUpdateIssueCommentHandler(t *testing.T) {
67516751
expectToolError: true,
67526752
expectedToolErrMsg: "missing required parameter: body",
67536753
},
6754+
{
6755+
name: "empty body",
6756+
requestArgs: map[string]any{
6757+
"owner": "owner",
6758+
"repo": "repo",
6759+
"comment_id": float64(456),
6760+
"body": "",
6761+
},
6762+
expectToolError: true,
6763+
expectedToolErrMsg: "body cannot be empty when provided",
6764+
},
67546765
{
67556766
name: "negative comment ID",
67566767
requestArgs: map[string]any{

0 commit comments

Comments
 (0)