8000 Fix: Allow null for avatar_url in GitLab schemas by ganniterix · Pull Request #85 · zereight/gitlab-mcp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: Allow null for avatar_url in GitLab schemas #85

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 4, 2025

Conversation

ganniterix
Copy link
Contributor
@ganniterix ganniterix commented Jun 4, 2025

This PR fixes a validation error in the search_repositories MCP call where items.0.owner.avatar_url was expected to be a string but received null from the GitLab API.

Closes #84

Problem Solved:
The GitLab API can return null for a user's avatar_url if they haven't set one. The existing schemas in schemas.ts did not account for this, defining avatar_url strictly as z.string(), leading to validation errors [1].

Changes Made:
The avatar_url field has been made nullable in the relevant Zod schemas within schemas.ts:

  1. GitLabOwnerSchema (around line 255):

    // Repository related schemas
    export const GitLabOwnerSchema = z.object({
      username: z.string(), // Changed from login to match GitLab API
      id: z.number(),
    - avatar_url: z.string(),
    + avatar_url: z.string().nullable(),
      web_url: z.string(), // Changed from html_url to match GitLab API
      name: z.string(), // Added as GitLab includes full name
      state: z.string(), // Added as GitLab includes user state
    });

    [1]

  2. Union type for user object (around line 214):

      z.string(),
      z.object({
        id: z.number(),
        username: z.string(),
        name: z.string(),
    -   avatar_url: z.string(),
    +   avatar_url: z.string().nullable(),
        web_url: z.string(),
      }).nullable()
    );

    [1]

  3. GitLabForkParentSchema owner object (around line 595):

      owner: z
        .object({
          username: z.string(), // Changed from login to match GitLab API
          id: z.number(),
    -     avatar_url: z.string(),
    +     avatar_url: z.string().nullable(),
        })
        .optional(), // Made optional to handle cases where GitLab API doesn't include it

    [1]

These changes ensure that the schema validation correctly handles null values for avatar_url returned by the GitLab API.

Verification:
After applying these changes:

  1. A Docker build of gitlab-mcp was successfully completed.
  2. The search_repositories MCP call was executed again.
  3. The call completed successfully without the Invalid arguments: items.0.owner.avatar_url: Expected string, received null error, confirming the fix.

@bbang-dduck bbang-dduck merged commit 061e19d into zereight:main Jun 4, 2025
6 checks passed
@bbang-dduck
Copy link
Collaborator

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.

Bug: search_repositories MCP call fails with "avatar_url: Expected string, received null"
2 participants
0