Skip to content

Preserve label id in typed list_label output - #3925

Open
Shanmukh-l33t wants to merge 1 commit into
github:mainfrom
Shanmukh-l33t:fix/3923-label-id
Open

Shanmukh-l33t wants to merge 1 commit into
github:mainfrom
Shanmukh-l33t:fix/3923-label-id

Conversation

@Shanmukh-l33t

Copy link
Copy Markdown

Summary

The typed ListLabelsOutput (and get_label, which decodes into the same struct) dropped every label id. MinimalLabel now carries the identity field, so the typed output round-trips the legacy payload losslessly.

Why

Fixes #3923

list_label emits each label as {"id": ..., "name": ..., "color": ..., "description": ...}, but MinimalLabel only declared name, color and description. encoding/json silently discarded id, so any client using the typed output lost label identity.

What changed

  • pkg/github/typed_governance_outputs.go: add ID string json:"id"`` as the first field of MinimalLabel. No other structs touched.
  • pkg/github/typed_governance_outputs_test.go: add TestListLabelsOutputPreservesLabelID (round-trip of a legacy payload with id, plus a decode of a payload without one) and update the two wire projection expectations that asserted the id-dropped shape.
  • pkg/github/__toolsnaps__/get_label.snap, list_label.snap: regenerated with UPDATE_TOOLSNAPS=true; the output schema gains id as a required string.

Field type differs from the issue's suggestion

The issue proposes ID int64. The producer does not emit a REST numeric id: pkg/github/labels.go writes "id": fmt.Sprintf("%v", labelNode.ID), a GraphQL node id string such as L1. An int64 field would make decode fail on every real response. string is also what the other typed label models already use (UIGetLabelOutput and IssueLabelOutput both declare ID string json:"id"), so this keeps the typed outputs consistent. Checked the remaining typed label structs for the same lossy pattern; both of those already keep id, so no other struct needs the change.

MCP impact

  • Tool schema or behavior changed
    get_label and list_label output schemas now include id. Tool inputs and names are unchanged; legacy text output was already emitting id and is unchanged.

Test evidence

Regression test on unmodified upstream/main (RED):

env -u PYTHONPATH go test ./pkg/github -run TestListLabelsOutputPreservesLabelID -count=1 -v
FAIL: TestListLabelsOutputPreservesLabelID (go test diff output)
    expected: {"labels":[{"color":"ff0000","description":"desc","id":"MDExOlB1bGxSZXBvc2l0b3J5TGFiZWwx","name":"bug"}, ...]}
    actual:   {"labels":[{"color":"ff0000","description":"desc","name":"bug"}, ...]}
FAIL	github.com/github/github-mcp-server/v2/pkg/github	0.005s

After the fix (GREEN):

=== RUN   TestListLabelsOutputPreservesLabelID
PASS: TestListLabelsOutputPreservesLabelID (0.00s)
PASS
ok  	github.com/github/github-mcp-server/v2/pkg/github	0.005s

Full package run:

env -u PYTHONPATH go test ./pkg/github -count=1 -p 2
ok  	github.com/github/github-mcp-server/v2/pkg/github	26.598s

Verbose run of the same package: 725 tests PASS, 2 SKIP (TestNewMCPServer_RegistersUIResources, TestRegisterUIResources_ReadableViaClient), 0 FAIL.

Static checks:

env -u PYTHONPATH go vet ./pkg/github          # exit 0
gofmt -l pkg/github                            # no output
env -u PYTHONPATH golangci-lint run ./pkg/github/...   # 0 issues
env -u PYTHONPATH go test ./pkg/skills/catalog -run TestCatalogToolRequirementsAreRegistered -count=1   # ok 0.042s
script/generate-docs                           # no diff

@Shanmukh-l33t
Shanmukh-l33t requested a review from a team as a code owner November 22, 2026 15:14
Copilot AI adaptive review requested due to automatic review settings November 22, 2026 15:14
MinimalLabel carried only name, color and description, so the typed
ListLabelsOutput decode silently dropped the id that list_label emits
(a GraphQL node id string). Typed output now round-trips the legacy
payload, and get_label keeps the id as well since it decodes into the
same struct.

Adds TestListLabelsOutputPreservesLabelID covering a legacy payload
with an id and one without, and refreshes the get_label and list_label
tool snapshots for the new output schema field.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change consistently adds label IDs to the shared typed model, includes round-trip and backward-compatible decoding coverage, and updates both affected output schemas.

No open issues 🎉

What changed in this PR

This PR preserves GraphQL label IDs in typed get_label and list_label outputs by adding the identity field to the shared MinimalLabel model.

Changes:

  • Added ID string to MinimalLabel.
  • Added round-trip and backward-compatible decoding coverage for label IDs.
  • Regenerated get_label and list_label output schema snapshots to include the required string ID.
File Description
pkg/​github/​typed_governance_outputs.go Adds the label ID field to the shared typed output model.
pkg/​github/​typed_governance_outputs_test.go Verifies label ID preservation during typed decoding and updates wire projections.
pkg/​github/​__toolsnaps__/​list_label.snap Updates the list_label output schema to include the required string ID.
pkg/​github/​__toolsnaps__/​get_label.snap Updates the get_label output schema to include the required string ID.

Review effort: Lite (adaptive)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ListLabelsOutput drops every label id from the typed response

3 participants