ListLabelsOutput drops every label id from the typed response

Aperta Adatta ai principianti
#3,923 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
api

Direzione di ricerca

Apri pkg/github/typed_governance_outputs.go e leggi MinimalLabel verso la riga 16 insieme al punto di decode intorno alla riga 461 che popola ListLabelsOutput. Aggiungi un campo ID int64 con il tag json:"id" a MinimalLabel in modo che l'identità legacy sopravviva a decode e re-encode, e verifica se lo schema di output necessita dello stesso campo. Poi aggiungi un test di round-trip (come il TestListLabelsDropsID segnalato) che asserisca che id è preservato ed esegui go test ./pkg/github.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Go
Stelle
34.4k
Fork
5.3k
Merge medio
4g 1h
PR unite (30g)
30

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di github/github-mcp-server

Tutte le issue di github/github-mcp-server

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.