ListLabelsOutput drops every label id from the typed response

Abierto Apto para principiantes
#3,923 0 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 4 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
88/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
api

Línea de trabajo

Abre pkg/github/typed_governance_outputs.go y lee MinimalLabel cerca de la línea 16, además del punto de decodificación alrededor de la línea 461 que rellena ListLabelsOutput. Añade un campo ID int64 con la etiqueta json:"id" a MinimalLabel para que la identidad heredada sobreviva a la decodificación y recodificación, y comprueba si el esquema de salida necesita el mismo campo. Después añade una prueba de ida y vuelta (como la reportada TestListLabelsDropsID) que afirme que id se conserva y ejecuta go test ./pkg/github.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Go
Estrellas
34.4k
Forks
5.3k
Merge medio
4 d 1 h
PR fusionados (30 d)
30

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de github/github-mcp-server

Todos los issues de github/github-mcp-server

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.