Repository navigation
Description
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.
Activity
media-ctrl commentedon Nov 26, 2026
Confirmed at HEAD: labels.go:107 writes id as fmt.Sprintf of query.Repository.Label.ID, so the emitted value is a STRING, and the find path at line 239 does the same. MinimalLabel has no destination for it (typed_governance_outputs.go:16) and the decode is the generic decodeGovernanceJSON, so the field is dropped without an error.
That changes the fix. A struct field typed int64 would fail to unmarshal the producer's string, so either the field is a string or the producer stops stringifying. The expected round trip in the report shows a number, which the legacy tool does not emit today.
The wider issue: typedGovernanceTool accepts any producer and struct pair and nothing checks the struct can hold every key the producer writes. A table test feeding each legacy producer's sample output through its Out type and asserting the re-marshalled keys cover the original set catches this one and the next one together, without depending on a reporter noticing the loss.
Worth deciding explicitly whether id belongs in the typed output at all: name is what the label endpoints key on.
Retain label id in typed governance outputs