Skip to content

Commit 4aefdf5

Browse files
HankGrimmclaude
andcommitted
Retain label id in typed governance outputs
MinimalLabel dropped the label's id on the typed get_label/list_label round-trip: it declared only name, color and description, so encoding/json silently ignored the legacy id field and re-encoding emitted no id. Add an ID field so the typed output preserves the label's GraphQL id. Fixes #3923 Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent 1a3b6a7 commit 4aefdf5

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎pkg/github/__toolsnaps__/get_label.snap‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@
3838
"description": {
3939
"type": "string"
4040
},
41+
"id": {
42+
"type": "string"
43+
},
4144
"name": {
4245
"type": "string"
4346
}
4447
},
4548
"required": [
49+
"id",
4650
"name",
4751
"color",
4852
"description"

‎pkg/github/__toolsnaps__/list_label.snap‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@
4747
"description": {
4848
"type": "string"
4949
},
50+
"id": {
51+
"type": "string"
52+
},
5053
"name": {
5154
"type": "string"
5255
}
5356
},
5457
"required": [
58+
"id",
5559
"name",
5660
"color",
5761
"description"

‎pkg/github/typed_governance_outputs.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
)
1515

1616
type MinimalLabel struct {
17+
ID string `json:"id"`
1718
Name string `json:"name"`
1819
Color string `json:"color" jsonschema:"Hex RGB without leading #."`
1920
Description string `json:"description"`

‎pkg/github/typed_governance_outputs_test.go‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ func assertGovernanceProjection(t *testing.T, tc governanceWireCase, output any)
7070
}
7171
switch tc.tool.Tool.Name {
7272
case "get_label":
73-
assert.JSONEq(t, `{"name":"bug","color":"ff0000","description":"desc"}`, mustMarshalJSON(t, output))
73+
assert.JSONEq(t, `{"id":"L1","name":"bug","color":"ff0000","description":"desc"}`, mustMarshalJSON(t, output))
7474
case "list_label":
75-
assert.JSONEq(t, `{"labels":[{"name":"bug","color":"ff0000","description":"desc"}],"totalCount":1,"pageInfo":{"hasNextPage":false,"hasPreviousPage":false}}`, mustMarshalJSON(t, output))
75+
assert.JSONEq(t, `{"labels":[{"id":"L1","name":"bug","color":"ff0000","description":"desc"}],"totalCount":1,"pageInfo":{"hasNextPage":false,"hasPreviousPage":false}}`, mustMarshalJSON(t, output))
7676
case "label_write":
7777
assert.Equal(t, tc.args["method"], object["method"])
7878
assert.Equal(t, tc.text, object["message"])
@@ -346,6 +346,20 @@ func TestTypedGovernanceWireOutputs(t *testing.T) {
346346
}
347347
}
348348

349+
func TestListLabelsOutputRetainsID(t *testing.T) {
350+
const legacy = `{"labels":[{"id":"LA_kwDOABcdEf","name":"bug","color":"ff0000","description":"desc"}],"totalCount":1,"pageInfo":{"hasNextPage":false,"hasPreviousPage":false}}`
351+
352+
var out ListLabelsOutput
353+
require.NoError(t, json.Unmarshal([]byte(legacy), &out))
354+
require.Len(t, out.Labels, 1)
355+
assert.Equal(t, "LA_kwDOABcdEf", out.Labels[0].ID)
356+
357+
// Round-trip: the id must survive a typed decode/re-encode.
358+
b, err := json.Marshal(out)
359+
require.NoError(t, err)
360+
assert.Contains(t, string(b), `"id":"LA_kwDOABcdEf"`)
361+
}
362+
349363
func TestRuleSuiteOutputFidelity(t *testing.T) {
350364
for _, sourceID := range []string{"null", "0", "7"} {
351365
for _, method := range []string{"get_rule_suite", "list_rule_suites"} {

0 commit comments

Comments
 (0)