Skip to content

Commit c5226df

Browse files
tommaso-moroCopilot
andcommitted
Normalize issue dependency ref state to match other tools
The REST issue-dependency endpoints return lower-case issue states (open/closed), whereas the previous GraphQL implementation and the sibling get_parent tool populate MinimalIssueRef.State from the GraphQL IssueState enum (OPEN/CLOSED). Upper-case the state in issueToDependencyRef so the field stays consistent across every tool that emits a MinimalIssueRef, and guard against a nil issue while here. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 5e5e7ec commit c5226df

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

pkg/github/issue_dependencies.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,17 @@ func dependencyReadResult(issues []*github.Issue, resp *github.Response) *mcp.Ca
164164

165165
// issueToDependencyRef converts a REST issue into the compact reference used by
166166
// the dependency tools, deriving the "owner/repo" name from the issue's
167-
// repository URL.
167+
// repository URL. The state is upper-cased so it matches the GraphQL-sourced
168+
// state (e.g. "OPEN"/"CLOSED") that MinimalIssueRef carries for the other issue
169+
// tools such as get_parent, keeping the field consistent across tools.
168170
func issueToDependencyRef(issue *github.Issue) MinimalIssueRef {
171+
if issue == nil {
172+
return MinimalIssueRef{}
173+
}
169174
ref := MinimalIssueRef{
170175
Number: issue.GetNumber(),
171176
Title: issue.GetTitle(),
172-
State: issue.GetState(),
177+
State: strings.ToUpper(issue.GetState()),
173178
URL: issue.GetHTMLURL(),
174179
}
175180
if owner, repo, ok := parseRepositoryURL(issue.GetRepositoryURL()); ok {

pkg/github/issue_dependencies_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func Test_IssueDependencyRead(t *testing.T) {
8888
option MockBackendOption
8989
expectedCount int
9090
expectedFirst int
91+
expectedState string
9192
expectedNext bool
9293
}{
9394
{
@@ -96,6 +97,7 @@ func Test_IssueDependencyRead(t *testing.T) {
9697
option: WithRequestMatch(endpointBlockedBy, blockedByIssues),
9798
expectedCount: 1,
9899
expectedFirst: 7,
100+
expectedState: "OPEN",
99101
expectedNext: false,
100102
},
101103
{
@@ -104,6 +106,7 @@ func Test_IssueDependencyRead(t *testing.T) {
104106
option: WithRequestMatchHandler(endpointBlocking, blockingHandler),
105107
expectedCount: 2,
106108
expectedFirst: 8,
109+
expectedState: "OPEN",
107110
expectedNext: true,
108111
},
109112
}
@@ -136,6 +139,9 @@ func Test_IssueDependencyRead(t *testing.T) {
136139
require.Len(t, payload.Issues, tc.expectedCount)
137140
assert.Equal(t, tc.expectedFirst, payload.Issues[0].Number)
138141
assert.Equal(t, "owner/repo", payload.Issues[0].Repository)
142+
// State is normalized to upper case to match the GraphQL-sourced
143+
// state used by other MinimalIssueRef producers (e.g. get_parent).
144+
assert.Equal(t, tc.expectedState, payload.Issues[0].State)
139145
assert.Equal(t, tc.expectedNext, payload.PageInfo.HasNextPage)
140146
})
141147
}

0 commit comments

Comments
 (0)