8000 fix: avoid error caused by line_range type: null in discussion by pxpeterxu · Pull Request #107 · zereight/gitlab-mcp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: avoid error caused by line_range type: null in discussion #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

pxpeterxu
Copy link
Contributor

Motivation

While testing the mr_discussions tool in MCP with Cursor, I encountered the following error for certain MRs:

⏺ GitLab:mr_discussions (MCP)(project_id: "...", merge_request_iid: 9156)…
  ⎿  Error: MCP error -32603: Invalid arguments: 0.notes.0.position.line_range.end.type: Required

Looking at the underlying API response, the issue was caused by a line_range block that did not include a type field. For example:

"line_range": {
  "start": {
    "line_code": "709d83f82c721d666fe983bab82fafc2b75e79d6_67_65",
    "type": null,
    "old_line": 67,
    "new_line": 65
  },
  "end": {
    "line_code": "709d83f82c721d666fe983bab82fafc2b75e79d6_69_67",
    "type": null,
    "old_line": 69,
    "new_line": null
  }
}

In this case, end.type was not just one of new/old/expandable but null.

Changes

Updated the zod schema for line_range to use the common LineRangeSchema, which already had type as nullable

Testing

Confirmed that running the mr_discussions tool against the affected MR now works as expected using the following mcp.json configuration:

{
  "mcpServers": {
    "GitLab": {
      "command": "npx",
      "args": ["-y", "github:wanderlog/gitlab-mcp"],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "glpat-..."
      }
    }
  }
}
image
Full JSON of erroring response
{
  "items": [
    {
      "id": "49c2eb8b154f939a82c521f897234b2446bea3c1",
      "individual_note": false,
      "notes": [
        {
          "id": 2568940190,
          "type": "DiffNote",
          "body": "Nit, since we're note passing in variant anymore, can you just pass in `defaultInputs` without destructuring it?",
          "author": {
            "username": "johndoe",
            "id": 21588835,
            "name": "John Doe",
            "avatar_url": "https://secure.gravatar.com/avatar/0cfdf18af5d52525ae4fd2f837780a997913a9d01dcfb5d363318ab24344185c?s=80&d=identicon",
            "web_url": "https://gitlab.com/johndoe"
          },
          "created_at": "2025-06-17T19:57:10.740Z",
          "updated_at": "2025-06-17T19:57:10.740Z",
          "system": false,
          "noteable_id": 391825028,
          "noteable_type": "MergeRequest",
          "project_id": 9347980,
          "noteable_iid": 9156,
          "resolvable": true,
          "resolved": false,
          "resolved_by": null,
          "resolved_at": null,
          "position": {
            "base_sha": "e76bdae00d127d01909774f5739c02e9b8c4fdf4",
            "start_sha": "e76bdae00d127d01909774f5739c02e9b8c4fdf4",
            "head_sha": "1d91425520553846b1b779647dc5e1c3b466a03a",
            "old_path": "mobile/templates/GuidedNewTripPlanScreen/CreateTripOnboardingSurvey/makeCreateTripOnboardingSurveySlides.test.ts",
            "new_path": "mobile/templates/GuidedNewTripPlanScreen/CreateTripOnboardingSurvey/makeCreateTripOnboardingSurveySlides.test.ts",
            "position_type": "text",
            "new_line": null,
            "old_line": 69,
            "line_range": {
              "start": {
                "line_code": "709d83f82c721d666fe983bab82fafc2b75e79d6_67_65",
                "type": null,
                "old_line": 67,
                "new_line": 65
              },
              "end": {
                "line_code": "709d83f82c721d666fe983bab82fafc2b75e79d6_69_67",
                "type": "old",
                "old_line": 69,
                "new_line": null
              }
            }
          }
        }
      ]
    }
  ],
  "pagination": {
    "x_next_page": null,
    "x_page": 1,
    "x_per_page": 100,
    "x_prev_page": null,
    "x_total": 1,
    "x_total_pages": 1
  }
}

@iwakitakuma33
Copy link
Collaborator

@pxpeterxu
thanks for your PR.

@iwakitakuma33 iwakitakuma33 merged commit 7db9139 into zereight:main Jun 18, 2025
7 checks passed
@iwakitakuma33
Copy link
Collaborator

@pxpeterxu thanks for your PR.

line_range is complex. so AI often can't recognize API specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0