Skip to content

Commit 6830c4d

Browse files
Change confidence enum to use uppercase values to match GraphQL schema (#2715)
* Fix enum values to match those expected by gql * Update test * Update doc and snaps * Normalize lower case confidence values --------- Co-authored-by: Ross Tarrant <rosstarrant@github.com>
1 parent f9a4dc5 commit 6830c4d

6 files changed

Lines changed: 85 additions & 46 deletions

File tree

docs/feature-flags.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ runtime behavior (such as output formatting) won't appear here.
222222

223223
- **update_issue_type** - Update Issue Type
224224
- **Required OAuth Scopes**: `repo`
225-
- `confidence`: How confident you are in this choice. Use 'high' for clear signal or explicit user request, 'medium' for reasonable inference with some ambiguity, 'low' for best guess with limited signal. (string, optional)
225+
- `confidence`: How confident you are in this choice. Use 'HIGH' for clear signal or explicit user request, 'MEDIUM' for reasonable inference with some ambiguity, 'LOW' for best guess with limited signal. (string, optional)
226226
- `is_suggestion`: If true, this issue type change is sent to the API as a suggestion (suggest:true) rather than an applied value. Whether the type is applied or recorded as a proposal is determined by the API. (boolean, optional)
227227
- `issue_number`: The issue number to update (number, required)
228228
- `issue_type`: The issue type to set (string, required)

pkg/github/__toolsnaps__/set_issue_fields.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
"items": {
1313
"properties": {
1414
"confidence": {
15-
"description": "How confident you are in this choice. Use 'high' for clear signal or explicit user request, 'medium' for reasonable inference with some ambiguity, 'low' for best guess with limited signal.",
15+
"description": "How confident you are in this choice. Use 'HIGH' for clear signal or explicit user request, 'MEDIUM' for reasonable inference with some ambiguity, 'LOW' for best guess with limited signal.",
1616
"enum": [
17-
"low",
18-
"medium",
19-
"high"
17+
"LOW",
18+
"MEDIUM",
19+
"HIGH"
2020
],
2121
"type": "string"
2222
},

pkg/github/__toolsnaps__/update_issue_labels.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"openWorldHint": true,
55
"title": "Update Issue Labels"
66
},
7-
"description": "Update the labels of an existing issue. This replaces the current labels with the provided list. When setting values, include a confidence level (low, medium, or high) reflecting how certain you are about the choice.",
7+
"description": "Update the labels of an existing issue. This replaces the current labels with the provided list. When setting values, include a confidence level (LOW, MEDIUM, or HIGH) reflecting how certain you are about the choice.",
88
"inputSchema": {
99
"properties": {
1010
"issue_number": {
@@ -23,11 +23,11 @@
2323
{
2424
"properties": {
2525
"confidence": {
26-
"description": "How confident you are in this choice. Use 'high' for clear signal or explicit user request, 'medium' for reasonable inference with some ambiguity, 'low' for best guess with limited signal.",
26+
"description": "How confident you are in this choice. Use 'HIGH' for clear signal or explicit user request, 'MEDIUM' for reasonable inference with some ambiguity, 'LOW' for best guess with limited signal.",
2727
"enum": [
28-
"low",
29-
"medium",
30-
"high"
28+
"LOW",
29+
"MEDIUM",
30+
"HIGH"
3131
],
3232
"type": "string"
3333
},

pkg/github/__toolsnaps__/update_issue_type.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"openWorldHint": true,
55
"title": "Update Issue Type"
66
},
7-
"description": "Update the type of an existing issue (e.g. 'bug', 'feature'). When setting values, include a confidence level (low, medium, or high) reflecting how certain you are about the choice.",
7+
"description": "Update the type of an existing issue (e.g. 'bug', 'feature'). When setting values, include a confidence level (LOW, MEDIUM, or HIGH) reflecting how certain you are about the choice.",
88
"inputSchema": {
99
"properties": {
1010
"confidence": {
11-
"description": "How confident you are in this choice. Use 'high' for clear signal or explicit user request, 'medium' for reasonable inference with some ambiguity, 'low' for best guess with limited signal.",
11+
"description": "How confident you are in this choice. Use 'HIGH' for clear signal or explicit user request, 'MEDIUM' for reasonable inference with some ambiguity, 'LOW' for best guess with limited signal.",
1212
"enum": [
13-
"low",
14-
"medium",
15-
"high"
13+
"LOW",
14+
"MEDIUM",
15+
"HIGH"
1616
],
1717
"type": "string"
1818
},

pkg/github/granular_tools_test.go

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,12 @@ func TestGranularUpdateIssueLabelsConfidence(t *testing.T) {
476476
"repo": "repo",
477477
"issue_number": float64(1),
478478
"labels": []any{
479-
map[string]any{"name": "bug", "confidence": "high"},
479+
map[string]any{"name": "bug", "confidence": "HIGH"},
480480
},
481481
},
482482
expectedReq: map[string]any{
483483
"labels": []any{
484-
map[string]any{"name": "bug", "confidence": "high"},
484+
map[string]any{"name": "bug", "confidence": "HIGH"},
485485
},
486486
},
487487
},
@@ -492,12 +492,28 @@ func TestGranularUpdateIssueLabelsConfidence(t *testing.T) {
492492
"repo": "repo",
493493
"issue_number": float64(1),
494494
"labels": []any{
495-
map[string]any{"name": "bug", "rationale": "Reports a crash", "confidence": "medium"},
495+
map[string]any{"name": "bug", "rationale": "Reports a crash", "confidence": "MEDIUM"},
496496
},
497497
},
498498
expectedReq: map[string]any{
499499
"labels": []any{
500-
map[string]any{"name": "bug", "rationale": "Reports a crash", "confidence": "medium"},
500+
map[string]any{"name": "bug", "rationale": "Reports a crash", "confidence": "MEDIUM"},
501+
},
502+
},
503+
},
504+
{
505+
name: "label confidence is normalized",
506+
requestArgs: map[string]any{
507+
"owner": "owner",
508+
"repo": "repo",
509+
"issue_number": float64(1),
510+
"labels": []any{
511+
map[string]any{"name": "bug", "confidence": " high\t"},
512+
},
513+
},
514+
expectedReq: map[string]any{
515+
"labels": []any{
516+
map[string]any{"name": "bug", "confidence": "HIGH"},
501517
},
502518
},
503519
},
@@ -528,7 +544,7 @@ func TestGranularUpdateIssueLabelsConfidence(t *testing.T) {
528544
require.NoError(t, err)
529545

530546
errorContent := getErrorResult(t, result)
531-
assert.Contains(t, errorContent.Text, "confidence must be one of: low, medium, high")
547+
assert.Contains(t, errorContent.Text, "confidence must be one of: LOW, MEDIUM, HIGH")
532548
return
533549
}
534550

@@ -742,12 +758,12 @@ func TestGranularUpdateIssueTypeConfidence(t *testing.T) {
742758
"repo": "repo",
743759
"issue_number": float64(1),
744760
"issue_type": "bug",
745-
"confidence": "high",
761+
"confidence": "HIGH",
746762
},
747763
expectedReq: map[string]any{
748764
"type": map[string]any{
749765
"value": "bug",
750-
"confidence": "high",
766+
"confidence": "HIGH",
751767
},
752768
},
753769
},
@@ -759,13 +775,13 @@ func TestGranularUpdateIssueTypeConfidence(t *testing.T) {
759775
"issue_number": float64(1),
760776
"issue_type": "feature",
761777
"rationale": "Asks for dark mode support",
762-
"confidence": "medium",
778+
"confidence": "MEDIUM",
763779
},
764780
expectedReq: map[string]any{
765781
"type": map[string]any{
766782
"value": "feature",
767783
"rationale": "Asks for dark mode support",
768-
"confidence": "medium",
784+
"confidence": "MEDIUM",
769785
},
770786
},
771787
},
@@ -776,12 +792,28 @@ func TestGranularUpdateIssueTypeConfidence(t *testing.T) {
776792
"repo": "repo",
777793
"issue_number": float64(1),
778794
"issue_type": "bug",
779-
"confidence": "low",
795+
"confidence": "LOW",
796+
},
797+
expectedReq: map[string]any{
798+
"type": map[string]any{
799+
"value": "bug",
800+
"confidence": "LOW",
801+
},
802+
},
803+
},
804+
{
805+
name: "type confidence is normalized",
806+
requestArgs: map[string]any{
807+
"owner": "owner",
808+
"repo": "repo",
809+
"issue_number": float64(1),
810+
"issue_type": "bug",
811+
"confidence": " medium ",
780812
},
781813
expectedReq: map[string]any{
782814
"type": map[string]any{
783815
"value": "bug",
784-
"confidence": "low",
816+
"confidence": "MEDIUM",
785817
},
786818
},
787819
},
@@ -820,7 +852,7 @@ func TestGranularUpdateIssueTypeInvalidConfidence(t *testing.T) {
820852
"issue_type": "bug",
821853
"confidence": "very_high",
822854
},
823-
expectedErrText: "confidence must be one of: low, medium, high",
855+
expectedErrText: "confidence must be one of: LOW, MEDIUM, HIGH",
824856
},
825857
{
826858
name: "confidence wrong type",
@@ -1599,7 +1631,7 @@ func TestGranularSetIssueFields(t *testing.T) {
15991631
})
16001632

16011633
t.Run("successful set with confidence", func(t *testing.T) {
1602-
confidence := "high"
1634+
confidence := "HIGH"
16031635
matchers := []githubv4mock.Matcher{
16041636
githubv4mock.NewQueryMatcher(
16051637
struct {
@@ -1680,7 +1712,7 @@ func TestGranularSetIssueFields(t *testing.T) {
16801712
map[string]any{
16811713
"field_id": "FIELD_1",
16821714
"text_value": "hello",
1683-
"confidence": "high",
1715+
"confidence": " high ",
16841716
},
16851717
},
16861718
})
@@ -1709,11 +1741,11 @@ func TestGranularSetIssueFields(t *testing.T) {
17091741
result, err := handler(ContextWithDeps(context.Background(), deps), &request)
17101742
require.NoError(t, err)
17111743
textContent := getTextResult(t, result)
1712-
assert.Contains(t, textContent.Text, "confidence must be one of: low, medium, high")
1744+
assert.Contains(t, textContent.Text, "confidence must be one of: LOW, MEDIUM, HIGH")
17131745
})
17141746

17151747
t.Run("confidence is sent when supplied", func(t *testing.T) {
1716-
confidence := "high"
1748+
confidence := "HIGH"
17171749
matchers := []githubv4mock.Matcher{
17181750
githubv4mock.NewQueryMatcher(
17191751
struct {
@@ -1794,7 +1826,7 @@ func TestGranularSetIssueFields(t *testing.T) {
17941826
map[string]any{
17951827
"field_id": "FIELD_1",
17961828
"text_value": "hello",
1797-
"confidence": "high",
1829+
"confidence": "HIGH",
17981830
},
17991831
},
18001832
})

pkg/github/issues_granular.go

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import (
1919
"github.com/shurcooL/githubv4"
2020
)
2121

22+
func normalizeConfidence(confidence string) string {
23+
return strings.ToUpper(strings.TrimSpace(confidence))
24+
}
25+
2226
// issueUpdateTool is a helper to create single-field issue update tools.
2327
func issueUpdateTool(
2428
t translations.TranslationHelperFunc,
@@ -281,7 +285,7 @@ func GranularUpdateIssueLabels(t translations.TranslationHelperFunc) inventory.S
281285
ToolsetMetadataIssues,
282286
mcp.Tool{
283287
Name: "update_issue_labels",
284-
Description: t("TOOL_UPDATE_ISSUE_LABELS_DESCRIPTION", "Update the labels of an existing issue. This replaces the current labels with the provided list. When setting values, include a confidence level (low, medium, or high) reflecting how certain you are about the choice."),
288+
Description: t("TOOL_UPDATE_ISSUE_LABELS_DESCRIPTION", "Update the labels of an existing issue. This replaces the current labels with the provided list. When setting values, include a confidence level (LOW, MEDIUM, or HIGH) reflecting how certain you are about the choice."),
285289
Annotations: &mcp.ToolAnnotations{
286290
Title: t("TOOL_UPDATE_ISSUE_LABELS_USER_TITLE", "Update Issue Labels"),
287291
ReadOnlyHint: false,
@@ -325,8 +329,8 @@ func GranularUpdateIssueLabels(t translations.TranslationHelperFunc) inventory.S
325329
},
326330
"confidence": {
327331
Type: "string",
328-
Description: "How confident you are in this choice. Use 'high' for clear signal or explicit user request, 'medium' for reasonable inference with some ambiguity, 'low' for best guess with limited signal.",
329-
Enum: []any{"low", "medium", "high"},
332+
Description: "How confident you are in this choice. Use 'HIGH' for clear signal or explicit user request, 'MEDIUM' for reasonable inference with some ambiguity, 'LOW' for best guess with limited signal.",
333+
Enum: []any{"LOW", "MEDIUM", "HIGH"},
330334
},
331335
"is_suggestion": {
332336
Type: "boolean",
@@ -398,8 +402,9 @@ func GranularUpdateIssueLabels(t translations.TranslationHelperFunc) inventory.S
398402
if err != nil {
399403
return utils.NewToolResultError(err.Error()), nil, nil
400404
}
401-
if confidence != "" && confidence != "low" && confidence != "medium" && confidence != "high" {
402-
return utils.NewToolResultError("confidence must be one of: low, medium, high"), nil, nil
405+
confidence = normalizeConfidence(confidence)
406+
if confidence != "" && confidence != "LOW" && confidence != "MEDIUM" && confidence != "HIGH" {
407+
return utils.NewToolResultError("confidence must be one of: LOW, MEDIUM, HIGH"), nil, nil
403408
}
404409
isSuggestion, err := OptionalParam[bool](v, "is_suggestion")
405410
if err != nil {
@@ -505,7 +510,7 @@ func GranularUpdateIssueType(t translations.TranslationHelperFunc) inventory.Ser
505510
ToolsetMetadataIssues,
506511
mcp.Tool{
507512
Name: "update_issue_type",
508-
Description: t("TOOL_UPDATE_ISSUE_TYPE_DESCRIPTION", "Update the type of an existing issue (e.g. 'bug', 'feature'). When setting values, include a confidence level (low, medium, or high) reflecting how certain you are about the choice."),
513+
Description: t("TOOL_UPDATE_ISSUE_TYPE_DESCRIPTION", "Update the type of an existing issue (e.g. 'bug', 'feature'). When setting values, include a confidence level (LOW, MEDIUM, or HIGH) reflecting how certain you are about the choice."),
509514
Annotations: &mcp.ToolAnnotations{
510515
Title: t("TOOL_UPDATE_ISSUE_TYPE_USER_TITLE", "Update Issue Type"),
511516
ReadOnlyHint: false,
@@ -540,8 +545,8 @@ func GranularUpdateIssueType(t translations.TranslationHelperFunc) inventory.Ser
540545
},
541546
"confidence": {
542547
Type: "string",
543-
Description: "How confident you are in this choice. Use 'high' for clear signal or explicit user request, 'medium' for reasonable inference with some ambiguity, 'low' for best guess with limited signal.",
544-
Enum: []any{"low", "medium", "high"},
548+
Description: "How confident you are in this choice. Use 'HIGH' for clear signal or explicit user request, 'MEDIUM' for reasonable inference with some ambiguity, 'LOW' for best guess with limited signal.",
549+
Enum: []any{"LOW", "MEDIUM", "HIGH"},
545550
},
546551
"is_suggestion": {
547552
Type: "boolean",
@@ -582,8 +587,9 @@ func GranularUpdateIssueType(t translations.TranslationHelperFunc) inventory.Ser
582587
if err != nil {
583588
return utils.NewToolResultError(err.Error()), nil, nil
584589
}
585-
if confidence != "" && confidence != "low" && confidence != "medium" && confidence != "high" {
586-
return utils.NewToolResultError("confidence must be one of: low, medium, high"), nil, nil
590+
confidence = normalizeConfidence(confidence)
591+
if confidence != "" && confidence != "LOW" && confidence != "MEDIUM" && confidence != "HIGH" {
592+
return utils.NewToolResultError("confidence must be one of: LOW, MEDIUM, HIGH"), nil, nil
587593
}
588594
isSuggestion, err := OptionalParam[bool](args, "is_suggestion")
589595
if err != nil {
@@ -987,8 +993,8 @@ func GranularSetIssueFields(t translations.TranslationHelperFunc) inventory.Serv
987993
},
988994
"confidence": {
989995
Type: "string",
990-
Description: "How confident you are in this choice. Use 'high' for clear signal or explicit user request, 'medium' for reasonable inference with some ambiguity, 'low' for best guess with limited signal.",
991-
Enum: []any{"low", "medium", "high"},
996+
Description: "How confident you are in this choice. Use 'HIGH' for clear signal or explicit user request, 'MEDIUM' for reasonable inference with some ambiguity, 'LOW' for best guess with limited signal.",
997+
Enum: []any{"LOW", "MEDIUM", "HIGH"},
992998
},
993999
"is_suggestion": {
9941000
Type: "boolean",
@@ -1111,8 +1117,9 @@ func GranularSetIssueFields(t translations.TranslationHelperFunc) inventory.Serv
11111117
if err != nil {
11121118
return utils.NewToolResultError(err.Error()), nil, nil
11131119
}
1114-
if confidence != "" && confidence != "low" && confidence != "medium" && confidence != "high" {
1115-
return utils.NewToolResultError("confidence must be one of: low, medium, high"), nil, nil
1120+
confidence = normalizeConfidence(confidence)
1121+
if confidence != "" && confidence != "LOW" && confidence != "MEDIUM" && confidence != "HIGH" {
1122+
return utils.NewToolResultError("confidence must be one of: LOW, MEDIUM, HIGH"), nil, nil
11161123
}
11171124
if confidence != "" {
11181125
input.Confidence = &confidence

0 commit comments

Comments
 (0)