github / github/copilot-cli

Gemini Flash: one malformed MCP array enum breaks all prompts with HTTP 400

Đang mở
#4,835 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

triage
Ngôn ngữ chính
Shell
Star
11.2k
Fork
1.9k
Merge trung bình
14 giờ 16 phút
Pull request đã merge (30 ngày)
6

Mô tả

Type: Bug

Copilot CLI Version: 1.0.84-5
OS Version: Windows 11 x64
Model: gemini-3.7-flash

Summary

Having a single MCP tool whose schema contains an integer enum directly on an array property causes all requests to Gemini Flash to fail with an opaque HTTP 400 Bad Request error.

The error does not identify which MCP server, tool, or schema property caused the failure.

Steps to Reproduce
  1. Save schema-repro.mjs, gemini-bad.json, and gemini-fixed.json from the Reproducer files section below in the same directory. Node.js must be available.
  2. From that directory, run these native Copilot commands:
copilot --model gemini-3.7-flash --no-custom-instructions --additional-mcp-config "@gemini-bad.json" --available-tools schema_repro-probe_000 --allow-all-tools -p "Reply with exactly OK. Do not call tools."
copilot --model gemini-3.7-flash --no-custom-instructions --additional-mcp-config "@gemini-fixed.json" --available-tools schema_repro-probe_000 --allow-all-tools -p "Reply with exactly OK. Do not call tools."

Both commands advertise exactly one inert tool. There is no SDK dependency or shell helper.

The bad fixture defines:

{
  "type": "object",
  "properties": {
    "levels": {
      "type": ["array", "null"],
      "items": { "type": "integer" },
      "enum": [0, 1, 2, 3, 4, 25]
    }
  }
}
Actual Behaviour

The request immediately fails with:

Execution failed: 400 Bad Request (Request ID: ...)

Moving enum under items:

{
  "type": ["array", "null"],
  "items": {
    "type": "integer",
    "enum": [0, 1, 2, 3, 4, 25]
  }
}

completely resolves the issue and the request succeeds.

Native CLI results:

Input Schema Advertised tools Result
enum on array level 1 HTTP 400
enum under items 1 OK
Expected Behaviour

Copilot CLI should validate tool schemas client-side before sending them to the provider API, and report actionable errors identifying:

  • Server name
  • Tool name
  • Schema property path

For this fixture: schema_repro, probe_000, and /properties/levels/enum.

Failing that, the error message should include the provider's validation details instead of a generic 400 error.

Notes
  • Other schema constructs like plain integer enums ({"type": "integer", "enum": [0, 1]}) and nullable objects work fine.
  • Related to #4623, but specifically caused by array-level enums rather than nullable object unions.
Impact

A single malformed tool schema from any active MCP server silently breaks all model calls to Gemini without any indication of which server or tool is at fault.

Reproducer files
schema-repro.mjs
import { createInterface } from 'node:readline';

const mode = process.argv[2];
const count = Number(process.argv[3] ?? 1);
const allowedModes = ['array-enum-bad', 'array-enum-fixed', 'count'];

if (!allowedModes.includes(mode) ||
    !Number.isInteger(count) ||
    count < 1 ||
    count > 400) {
  throw new Error('Usage: node schema-repro.mjs array-enum-bad|array-enum-fixed|count [1..400]');
}

const levels = { type: ['array', 'null'], items: { type: 'integer' } };
if (mode === 'array-enum-bad') {
  levels.enum = [0, 1, 2, 3, 4, 25];
} else {
  levels.items.enum = [0, 1, 2, 3, 4, 25];
}

const tools = Array.from({ length: mode === 'count' ? count : 1 }, (_, index) => ({
  name: `probe_${String(index).padStart(3, '0')}`,
  description: 'Schema diagnostic only; performs no operation.',
  inputSchema: {
    type: 'object',
    properties: mode === 'count' ? { value: { type: 'string' } } : { levels },
  },
}));

for await (const line of createInterface({ input: process.stdin, crlfDelay: Infinity })) {
  if (!line.trim()) {
    continue;
  }
  const request = JSON.parse(line);
  if (request.id === undefined) {
    continue;
  }

  let result;
  if (request.method === 'initialize') {
    result = {
      protocolVersion: request.params.protocolVersion,
      capabilities: { tools: {} },
      serverInfo: { name: 'schema-repro', version: '1.0.0' },
    };
  } else if (request.method === 'tools/list') {
    result = { tools };
  } else if (request.method === 'tools/call') {
    result = {
      isError: true,
      content: [{ type: 'text', text: 'This diagnostic never executes an operation.' }],
    };
  } else if (request.method === 'ping') {
    result = {};
  } else {
    process.stdout.write(`${JSON.stringify({
      jsonrpc: '2.0',
      id: request.id,
      error: { code: -32601, message: 'Method not found' },
    })}\n`);
    continue;
  }

  process.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', id: request.id, result })}\n`);
}
gemini-bad.json
{
  "mcpServers": {
    "schema_repro": {
      "type": "stdio",
      "command": "node",
      "args": ["schema-repro.mjs", "array-enum-bad"],
      "tools": ["*"]
    }
  }
}
gemini-fixed.json
{
  "mcpServers": {
    "schema_repro": {
      "type": "stdio",
      "command": "node",
      "args": ["schema-repro.mjs", "array-enum-fixed"],
      "tools": ["*"]
    }
  }
}

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với schema-repro.mjs, gemini-bad.json và gemini-fixed.json, sau đó chạy hai lệnh Copilot gốc trong các bước tái hiện để xác nhận các trường hợp lỗi và thành công. Truy vết nơi các schema công cụ MCP được xử lý trước khi yêu cầu Gemini được gửi đi. Được xem là hoàn tất khi các enum không hợp lệ ở cấp mảng tạo ra lỗi có thể xử lý, nêu rõ schema_repro, probe_000 và /properties/levels/enum, hoặc hiển thị chi tiết xác thực của provider thay vì lỗi 400 chung chung.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, node.js
Lĩnh vực
api, cli
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
50/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.