Skip to content

Commit 3b53aaa

Browse files
committed
fix(#95): bad request error when use filter-by-assignee together with Jira Cloud API
1 parent 46ae0f1 commit 3b53aaa

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

internal/issues/jql_builder.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ func BuildSearchIssuesJql(project *jira.Project, query string, status *jira.Issu
2121
jql = jql + fmt.Sprintf(" AND status=%s", status.Id)
2222
}
2323
if user != nil && user.DisplayName != ui.MessageAll {
24-
jql = jql + fmt.Sprintf(" AND assignee=%s", user.AccountId)
24+
userId := user.AccountId
25+
if userId == "" {
26+
userId = user.Name
27+
}
28+
jql = jql + fmt.Sprintf(" AND assignee=%s", userId)
2529
}
2630
// TODO - would be safer to check the index of inserted all message, instead of checking it like this / same for all All checks
2731
if label != "" && label != ui.MessageAll {

internal/issues/jql_builder_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func Test_buildSearchIssuesJql(t *testing.T) {
3232
"project=123 AND summary~\"abc*\" AND status=st1 AND assignee=us1 ORDER BY status",
3333
},
3434
{"should create valid jql", args{project: &jira.Project{Id: "123"}, label: "test"}, "project=123 AND labels=test ORDER BY status"},
35+
{"should create valid jql", args{project: &jira.Project{Id: "123"}, user: &jira.User{Name: "bob"}}, "project=123 AND assignee=bob ORDER BY status"},
3536
}
3637
for _, tt := range tests {
3738
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)