Skip to content

Issue: list_sprints 接口调用失败 - description 字段类型错误 #51

@1925197339

Description

@1925197339

问题描述

yunxiao/list_sprints 接口在查询特定状态的迭代时返回类型错误,导致调用失败。

错误信息

MCP error -32603: Invalid input: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "null",
    "path": ["description"],
    "message": "Expected string, received null"
  }
]

复现步骤

  1. 调用 list_sprints 接口
  2. 参数设置:status: ["DOING"]
  3. 接口返回错误

成功的情况

{
  "organizationId": "628exxxxxxxxxxxxx2970",
  "id": "c0d89xxxxxxxxxxxxxbf6d5",
  "page": 1,
  "perPage": 100,
  "status": ["TODO"]
}

✅ 返回正常

{
  "organizationId": "628exxxxxxxxxxxxx2970",
  "id": "c0d89xxxxxxxxxxxxxbf6d5",
  "page": 1,
  "perPage": 100,
  "status": ["ARCHIVED"]
}

✅ 返回正常

失败的情况

{
  "organizationId": "628exxxxxxxxxxxxx2970",
  "id": "c0d89xxxxxxxxxxxxxbf6d5",
  "page": 1,
  "perPage": 100,
  "status": ["DOING"]
}

❌ 返回类型错误

问题分析

API 返回的数据中,description 字段在某些迭代中为 null,但接口定义期望的是 string 类型。这可能是由于:

  1. 数据库中 description 字段允许为 NULL
  2. 接口的响应 schema 没有正确处理 null
  3. 只有特定状态(如 DOING)的迭代存在 descriptionnull 的情况

建议修复方案

  1. 方案一(推荐):修改接口响应 schema,允许 description 字段为 nullstring
    description: string | null
  2. 方案二:在返回数据前,将 null 值转换为空字符串
    description: data.description ?? ""

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions