ListLabelsOutput drops every label id from the typed response

オープン 初心者向け
#3,923 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
api

調査の方向性

pkg/github/typed_governance_outputs.go を開き、16 行目付近の MinimalLabel と、ListLabelsOutput を埋める 461 行目付近のデコード箇所を読んでください。MinimalLabel に json:"id" タグ付きの ID int64 フィールドを追加して、レガシーな identity がデコードと再エンコードを経ても残るようにし、出力スキーマにも同じフィールドが必要か確認してください。次に、id が保持されることを検証するラウンドトリップテスト(報告された TestListLabelsDropsID のようなもの)を追加し、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時間
マージ済み PR(30日)
30

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/github-mcp-server のほかの issue

github/github-mcp-server の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。