ListLabelsOutput drops every label id from the typed response

未關閉 適合新手
#3,923 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 4 天內回覆

還沒有人認領這個 Issue。

評估

難度
1/5
預估耗時
1 小時以內
新手友好度
88/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
go
領域
api

研究方向

打開 pkg/github/typed_governance_outputs.go,閱讀第 16 行附近的 MinimalLabel 以及第 461 行附近填充 ListLabelsOutput 的解碼位置。給 MinimalLabel 新增帶 json:"id" tag 的 ID int64 欄位,使舊有 identity 在解碼與重新編碼後仍能保留,並檢查輸出 schema 是否需要相同的欄位。接著新增一個往返測試(類似所回報的 TestListLabelsDropsID),斷言 id 會被保留,並執行 go test ./pkg/github。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Go
星號
34.4k
分支
5.3k
平均合併
4 天 1 小時
30 天內合併 PR
30

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

github/github-mcp-server 的其他 Issue

查看 github/github-mcp-server 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。