Skip to content

Add created_by filter to SearchIssues#36670

Open
danigm wants to merge 3 commits intogo-gitea:mainfrom
danigm:search-issues-created-by
Open

Add created_by filter to SearchIssues#36670
danigm wants to merge 3 commits intogo-gitea:mainfrom
danigm:search-issues-created-by

Conversation

@danigm
Copy link

@danigm danigm commented Feb 18, 2026

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.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 18, 2026
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Feb 18, 2026
@lunny
Copy link
Member

lunny commented Feb 18, 2026

Please run make generate-swagger before commit.

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.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a created_by query parameter to the SearchIssues API endpoint (GET /repos/issues/search) to enable filtering issues and pull requests by their creator's username. This feature is needed for the tea CLI tool which has an author filter option that was previously not working due to the missing API support.

Changes:

  • Added created_by parameter documentation to SearchIssues swagger comments
  • Implemented created_by parameter handling using the existing getUserIDForFilter helper
  • Manually updated swagger JSON template with the new parameter definition

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
routers/api/v1/repo/issue.go Added swagger documentation and implementation for the created_by query parameter in SearchIssues function
templates/swagger/v1_json.tmpl Manually added created_by parameter definition to the swagger specification (should be auto-generated instead)
Comments suppressed due to low confidence (1)

routers/api/v1/repo/issue.go:276

  • The interaction between created_by parameter and the created boolean parameter has a logic error. When both parameters are provided, the created boolean (line 274-276) will unconditionally overwrite the searchOpt.PosterID value set by created_by (line 268-270). This means that if a user requests issues created by a specific user via created_by=someuser and also sets created=true, the created_by filter will be ignored and only issues created by the authenticated user will be returned.

The intended behavior should likely be: if created=true is set, it takes precedence (filter by authenticated user). However, if created is not set or false, then created_by should be respected. The fix would be to only set PosterID from the authenticated user if created_by was not already specified, or to document that created=true takes precedence over created_by.

	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") {
			searchOpt.PosterID = strconv.FormatInt(ctxUserID, 10)
		}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +264 to +270
createdByID := getUserIDForFilter(ctx, "created_by")
if ctx.Written() {
return
}
if createdByID > 0 {
searchOpt.PosterID = strconv.FormatInt(createdByID, 10)
}
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new created_by parameter lacks test coverage. The existing test file tests/integration/api_issue_test.go has a TestAPISearchIssues function that tests various filters (assigned, milestones, owner, team), but does not include tests for the new created_by parameter. Consider adding test cases that verify:

  1. Filtering by a specific user with created_by=username
  2. The interaction between created=true and created_by=username
  3. Error handling when the specified user doesn't exist

Copilot uses AI. Check for mistakes.
@silverwind
Copy link
Member

silverwind commented Feb 19, 2026

Would be good to add a test case into TestAPISearchIssues.

@danigm
Copy link
Author

danigm commented Feb 19, 2026

Would be good to add a test case into TestAPISearchIssues.

I've just added a new commit with the new test case

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments