From 829bbd1389496e4198ed7c113b039ada717136a6 Mon Sep 17 00:00:00 2001 From: Daniel Garcia Moreno Date: Wed, 18 Feb 2026 15:11:41 +0100 Subject: [PATCH 1/2] Add created_by filter to SearchIssues This patch adds the created_by filter to the SearchIssues method. tea cli has an option to filter by author when listing issues, but it's not working. The tea command line creates this request for the API when using the author filter: $ tea issue list -l local --kind pull -A danigm -vvv http://localhost:3000/api/v1/repos/issues/search?created_by=danigm&labels=&limit=30&milestones=&page=1&state=open&type=pulls This patch fixes the API to allow this kind of queries from go-sdk and tea cli. --- routers/api/v1/repo/issue.go | 12 ++++++++++++ templates/swagger/v1_json.tmpl | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 41076fd99c..22324e1923 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -157,6 +157,10 @@ func SearchIssues(ctx *context.APIContext) { // in: query // description: Filter by repository owner // type: string + // - name: created_by + // in: query + // description: Only show items which were created by the given user + // type: string // - name: team // in: query // description: Filter by team (requires organization owner parameter) @@ -257,6 +261,14 @@ func SearchIssues(ctx *context.APIContext) { searchOpt.UpdatedBeforeUnix = optional.Some(before) } + createdByID := getUserIDForFilter(ctx, "created_by") + if ctx.Written() { + return + } + if createdByID > 0 { + searchOpt.PosterID = strconv.FormatInt(createdByID, 10) + } + if ctx.IsSigned { ctxUserID := ctx.Doer.ID if ctx.FormBool("created") { diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 570747ca57..1f4f30b908 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -4300,6 +4300,12 @@ "name": "owner", "in": "query" }, + { + "type": "string", + "description": "Only show items which were created by the given user", + "name": "created_by", + "in": "query" + }, { "type": "string", "description": "Filter by team (requires organization owner parameter)", From 834ca6f89c271809027e07c85f4623fa55f0d53b Mon Sep 17 00:00:00 2001 From: Daniel Garcia Moreno Date: Thu, 19 Feb 2026 19:39:15 +0100 Subject: [PATCH 2/2] Add test for repos/issues/search with created_by --- tests/integration/api_issue_test.go | 67 +++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/integration/api_issue_test.go b/tests/integration/api_issue_test.go index 56bed7db0d..734bc7d863 100644 --- a/tests/integration/api_issue_test.go +++ b/tests/integration/api_issue_test.go @@ -420,3 +420,70 @@ func TestAPISearchIssuesWithLabels(t *testing.T) { DecodeJSON(t, resp, &apiIssues) assert.Len(t, apiIssues, 2) } + +func TestAPISearchIssuesCreatedBy(t *testing.T) { + defer tests.PrepareTestEnv(t)() + defer test.MockVariableValue(&setting.API.DefaultPagingNum, 20)() + expectedIssueCount := 20 // 20 is from the fixtures + + link, _ := url.Parse("/api/v1/repos/issues/search") + token := getUserToken(t, "user1", auth_model.AccessTokenScopeReadIssue) + query := url.Values{} + var apiIssues []*api.Issue + + link.RawQuery = query.Encode() + req := NewRequest(t, "GET", link.String()).AddTokenAuth(token) + resp := MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiIssues) + assert.Len(t, apiIssues, expectedIssueCount) + + // Auth user, user1 created issues + query.Add("created", "1") + link.RawQuery = query.Encode() + req = NewRequest(t, "GET", link.String()).AddTokenAuth(token) + resp = MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiIssues) + assert.Len(t, apiIssues, 5) + + // Auth user, user1 created pull requests + query.Add("type", "pulls") + link.RawQuery = query.Encode() + req = NewRequest(t, "GET", link.String()).AddTokenAuth(token) + resp = MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiIssues) + assert.Len(t, apiIssues, 3) + + // user1 created issues, using created_by filter + query = url.Values{} + query.Add("created_by", "user1") + link.RawQuery = query.Encode() + req = NewRequest(t, "GET", link.String()).AddTokenAuth(token) + resp = MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiIssues) + assert.Len(t, apiIssues, 5) + + // user1 created pull requests, using created_by filter + query.Add("type", "pulls") + link.RawQuery = query.Encode() + req = NewRequest(t, "GET", link.String()).AddTokenAuth(token) + resp = MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiIssues) + assert.Len(t, apiIssues, 3) + + // user2 created issues, using created_by filter + query = url.Values{} + query.Add("created_by", "user2") + link.RawQuery = query.Encode() + req = NewRequest(t, "GET", link.String()).AddTokenAuth(token) + resp = MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiIssues) + assert.Len(t, apiIssues, 9) + + // user2 created pull requests, using created_by filter + query.Add("type", "pulls") + link.RawQuery = query.Encode() + req = NewRequest(t, "GET", link.String()).AddTokenAuth(token) + resp = MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiIssues) + assert.Len(t, apiIssues, 3) +}