diff --git a/pkg/github/__toolsnaps__/get_label.snap b/pkg/github/__toolsnaps__/get_label.snap index 6cd1ddb6aa..50a2081f5d 100644 --- a/pkg/github/__toolsnaps__/get_label.snap +++ b/pkg/github/__toolsnaps__/get_label.snap @@ -38,11 +38,15 @@ "description": { "type": "string" }, + "id": { + "type": "string" + }, "name": { "type": "string" } }, "required": [ + "id", "name", "color", "description" diff --git a/pkg/github/__toolsnaps__/list_label.snap b/pkg/github/__toolsnaps__/list_label.snap index 80e898b71b..e4c1665e9e 100644 --- a/pkg/github/__toolsnaps__/list_label.snap +++ b/pkg/github/__toolsnaps__/list_label.snap @@ -47,11 +47,15 @@ "description": { "type": "string" }, + "id": { + "type": "string" + }, "name": { "type": "string" } }, "required": [ + "id", "name", "color", "description" diff --git a/pkg/github/typed_governance_outputs.go b/pkg/github/typed_governance_outputs.go index 02952bac0b..d67e5daa2f 100644 --- a/pkg/github/typed_governance_outputs.go +++ b/pkg/github/typed_governance_outputs.go @@ -14,6 +14,7 @@ import ( ) type MinimalLabel struct { + ID string `json:"id"` Name string `json:"name"` Color string `json:"color" jsonschema:"Hex RGB without leading #."` Description string `json:"description"` diff --git a/pkg/github/typed_governance_outputs_test.go b/pkg/github/typed_governance_outputs_test.go index 094de91547..9bbc5bbc29 100644 --- a/pkg/github/typed_governance_outputs_test.go +++ b/pkg/github/typed_governance_outputs_test.go @@ -70,9 +70,9 @@ func assertGovernanceProjection(t *testing.T, tc governanceWireCase, output any) } switch tc.tool.Tool.Name { case "get_label": - assert.JSONEq(t, `{"name":"bug","color":"ff0000","description":"desc"}`, mustMarshalJSON(t, output)) + assert.JSONEq(t, `{"id":"L1","name":"bug","color":"ff0000","description":"desc"}`, mustMarshalJSON(t, output)) case "list_label": - assert.JSONEq(t, `{"labels":[{"name":"bug","color":"ff0000","description":"desc"}],"totalCount":1,"pageInfo":{"hasNextPage":false,"hasPreviousPage":false}}`, mustMarshalJSON(t, output)) + assert.JSONEq(t, `{"labels":[{"id":"L1","name":"bug","color":"ff0000","description":"desc"}],"totalCount":1,"pageInfo":{"hasNextPage":false,"hasPreviousPage":false}}`, mustMarshalJSON(t, output)) case "label_write": assert.Equal(t, tc.args["method"], object["method"]) assert.Equal(t, tc.text, object["message"]) @@ -346,6 +346,20 @@ func TestTypedGovernanceWireOutputs(t *testing.T) { } } +func TestListLabelsOutputRetainsID(t *testing.T) { + const legacy = `{"labels":[{"id":"LA_kwDOABcdEf","name":"bug","color":"ff0000","description":"desc"}],"totalCount":1,"pageInfo":{"hasNextPage":false,"hasPreviousPage":false}}` + + var out ListLabelsOutput + require.NoError(t, json.Unmarshal([]byte(legacy), &out)) + require.Len(t, out.Labels, 1) + assert.Equal(t, "LA_kwDOABcdEf", out.Labels[0].ID) + + // Round-trip: the id must survive a typed decode/re-encode. + b, err := json.Marshal(out) + require.NoError(t, err) + assert.Contains(t, string(b), `"id":"LA_kwDOABcdEf"`) +} + func TestRuleSuiteOutputFidelity(t *testing.T) { for _, sourceID := range []string{"null", "0", "7"} { for _, method := range []string{"get_rule_suite", "list_rule_suites"} {