Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions notify/jira/jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,13 @@ func (n *Notifier) searchExistingIssue(ctx context.Context, logger *slog.Logger,
return nil, false, err
}

if issueSearchResult.Total == 0 {
issuesCount := len(issueSearchResult.Issues)
if issuesCount == 0 {
logger.Debug("found no existing issue")
return nil, false, nil
}

if issueSearchResult.Total > 1 {
if issuesCount > 1 {
logger.Warn("more than one issue matched, selecting the most recently resolved", "selected_issue", issueSearchResult.Issues[0].Key)
}

Expand Down
10 changes: 2 additions & 8 deletions notify/jira/jira_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestSearchExistingIssue(t *testing.T) {
return
}
require.Equal(t, expectedJQL, data.JQL)
w.Write([]byte(`{"total": 0, "issues": []}`))
w.Write([]byte(`{"issues": []}`))
return
default:
dec := json.NewDecoder(r.Body)
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestJiraTemplating(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/search":
w.Write([]byte(`{"total": 0, "issues": []}`))
w.Write([]byte(`{"issues": []}`))
return
default:
dec := json.NewDecoder(r.Body)
Expand Down Expand Up @@ -464,7 +464,6 @@ func TestJiraNotify(t *testing.T) {
},
},
searchResponse: issueSearchResult{
Total: 0,
Issues: []issue{},
},
issue: issue{
Expand Down Expand Up @@ -509,7 +508,6 @@ func TestJiraNotify(t *testing.T) {
},
},
searchResponse: issueSearchResult{
Total: 0,
Issues: []issue{},
},
issue: issue{
Expand Down Expand Up @@ -562,7 +560,6 @@ func TestJiraNotify(t *testing.T) {
},
},
searchResponse: issueSearchResult{
Total: 0,
Issues: []issue{},
},
issue: issue{
Expand Down Expand Up @@ -612,7 +609,6 @@ func TestJiraNotify(t *testing.T) {
},
},
searchResponse: issueSearchResult{
Total: 1,
Issues: []issue{
{
Key: "OPS-1",
Expand Down Expand Up @@ -668,7 +664,6 @@ func TestJiraNotify(t *testing.T) {
},
},
searchResponse: issueSearchResult{
Total: 1,
Issues: []issue{
{
Key: "OPS-3",
Expand Down Expand Up @@ -723,7 +718,6 @@ func TestJiraNotify(t *testing.T) {
},
},
searchResponse: issueSearchResult{
Total: 1,
Issues: []issue{
{
Key: "OPS-3",
Expand Down
1 change: 0 additions & 1 deletion notify/jira/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type issueSearch struct {
}

type issueSearchResult struct {
Total int `json:"total"`
Issues []issue `json:"issues"`
}

Expand Down
Loading