ListLabelsOutput drops every label id from the typed response

Đang mở Phù hợp với người mới
#3,923 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 4 ngày

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

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
api

Hướng nghiên cứu

Mở pkg/github/typed_governance_outputs.go và đọc MinimalLabel gần dòng 16 cùng vị trí decode khoảng dòng 461 nơi điền ListLabelsOutput. Thêm trường ID int64 với tag json:"id" vào MinimalLabel để identity legacy tồn tại qua decode và re-encode, và kiểm tra xem schema đầu ra có cần cùng trường đó không. Sau đó thêm một test round-trip (giống TestListLabelsDropsID được báo cáo) khẳng định id được giữ nguyên và chạy go test ./pkg/github.

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

Mô tả

ListLabelsOutput drops every label id from the typed response

Summary

The legacy list_label producer serializes each label's id, but the typed ListLabelsOutput decodes into MinimalLabel, which has no id field. A round-trip through the typed output therefore removes every label id.

Location

  • Repository: github/github-mcp-server
  • File: pkg/github/typed_governance_outputs.go
  • Line: 16 (MinimalLabel; decode at 461)
  • Revision: e3809fe91c75

Affected code

type MinimalLabel struct {
    Name        string `json:"name"`
    Color       string `json:"color" jsonschema:"Hex RGB without leading #."`
    Description string `json:"description"`
}

type ListLabelsOutput struct {
    Labels     []MinimalLabel  `json:"labels"`
    TotalCount int             `json:"totalCount" jsonschema:"Total labels in the repository."`
    PageInfo   MinimalPageInfo `json:"pageInfo"`
}

The legacy JSON carries id, but the typed struct has no destination for it.

Expected behavior

A typed ListLabelsOutput preserves the legacy label identity. Round-tripping:

{"labels":[{"id":123,"name":"bug","color":"ff0000","description":""}],"totalCount":1,"pageInfo":{}}

must keep id: 123, or the typed output must not be used for a lossless interpretation of the legacy response.

Actual behavior

Running a round-trip test in Docker:

docker run --rm -v "$PWD:/app" -v /tmp/gomod:/go/pkg/mod -v /tmp/gocache:/root/.cache/go-build -w /app -e GOFLAGS=-mod=mod golang:1.26 bash -c 'go mod download && go test ./pkg/github -run TestListLabelsDropsID -v'

Observed:

roundtrip={"labels":[{"name":"bug","color":"ff0000","description":""}],"totalCount":1,"pageInfo":{"hasNextPage":false,"hasPreviousPage":false}}
--- PASS: TestListLabelsDropsID

id is gone after the typed decode/encode.

Root cause

MinimalLabel declares only name, color, and description. encoding/json silently ignores the legacy id field, and re-encoding the typed value emits no id.

The current default branch still has the same MinimalLabel definition.

Suggested fix

Add the identity field to the typed model:

type MinimalLabel struct {
    ID          int64  `json:"id"`
    Name        string `json:"name"`
    Color       string `json:"color" jsonschema:"Hex RGB without leading #."`
    Description string `json:"description"`
}

and include it in the output schema. Add a round-trip test asserting id survives.

Ngôn ngữ chính
Go
Star
34.4k
Fork
5.3k
Merge trung bình
4 ngày 1 giờ
Pull request đã merge (30 ngày)
30

Chuẩn bị môi trường

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.

Issue khác của github/github-mcp-server

Tất cả issue của github/github-mcp-server

Issue tương tự

Thêm issue về Go

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.