Skip to content

Add created_by filter to SearchIssues#36670

Merged
silverwind merged 5 commits intogo-gitea:mainfrom
danigm:search-issues-created-by
Feb 26, 2026
Merged

Add created_by filter to SearchIssues#36670
silverwind merged 5 commits intogo-gitea:mainfrom
danigm:search-issues-created-by

Conversation

@danigm
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
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.

@silverwind
Copy link
Copy Markdown
Member

silverwind commented Feb 19, 2026

Would be good to add a test case into TestAPISearchIssues.

@danigm
Copy link
Copy Markdown
Contributor 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
@wxiaoguang wxiaoguang marked this pull request as draft February 20, 2026 01:49
@danigm danigm force-pushed the search-issues-created-by branch from 834ca6f to 491f222 Compare February 23, 2026 09:51
@wxiaoguang wxiaoguang marked this pull request as ready for review February 26, 2026 09:01
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 26, 2026
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 26, 2026
@silverwind silverwind enabled auto-merge (squash) February 26, 2026 11:14
@silverwind silverwind merged commit d0f92cb into go-gitea:main Feb 26, 2026
26 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Feb 26, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 26, 2026
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 26, 2026
* main: (24 commits)
  Instance-wide (global) info banner and maintenance mode (go-gitea#36571)
  Add created_by filter to SearchIssues (go-gitea#36670)
  Inline and lazy-load EasyMDE CSS, fix border colors (go-gitea#36714)
  Fix release draft access check logic (go-gitea#36720)
  Change image transparency grid to CSS (go-gitea#36711)
  Avoid opening new tab when downloading actions logs (go-gitea#36740)
  Add validation constraints for repository creation fields (go-gitea#36671)
  Fix SVG height calculation in diff viewer (go-gitea#36748)
  Fix path resolving (go-gitea#36734)
  [skip ci] Updated translations via Crowdin
  Fix track time list permission check (go-gitea#36662)
  Fix incorrect setting loading order (go-gitea#36735)
  Use case-insensitive matching for Git error "Not a valid object name" (go-gitea#36728)
  feat: Add workflow dependencies visualization (go-gitea#36248)
  Add keyboard shortcuts for repository file and code search (go-gitea#36416)
  Refactor text utility classes to Tailwind CSS (go-gitea#36703)
  Prevent redirect bypasses via backslash-encoded paths (go-gitea#36660)
  Fix force push time-line commit comments of pull request (go-gitea#36653)
  Fix get release draft permission check (go-gitea#36659)
  Move `X_FRAME_OPTIONS` setting from `cors` to `security` section (go-gitea#30256)
  ...

# Conflicts:
#	web_src/css/base.css
#	web_src/css/index.css
zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 27, 2026
* giteaofficial/main:
  Filter out untracked files from spellchecking (go-gitea#36756)
  Fix CSS stacking context issue in actions log (go-gitea#36749)
  Fix milestone/project text overflow in issue sidebar (go-gitea#36741)
  Update tool dependencies and fix new lint issues (go-gitea#36702)
  Instance-wide (global) info banner and maintenance mode (go-gitea#36571)
  Add created_by filter to SearchIssues (go-gitea#36670)
  Inline and lazy-load EasyMDE CSS, fix border colors (go-gitea#36714)
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 27, 2026
* origin/main:
  Move Fomantic dropdown CSS to custom module (go-gitea#36530)
  Use "Enable Gravatar" but not "Disable" (go-gitea#36771)
  feat: add branch_count to repository API (go-gitea#35351) (go-gitea#36743)
  Deprecate RenderWithErr (go-gitea#36769)
  Lazy-load some Vue components, fix heatmap chunk loading on every page (go-gitea#36719)
  Filter out untracked files from spellchecking (go-gitea#36756)
  Fix CSS stacking context issue in actions log (go-gitea#36749)
  Fix milestone/project text overflow in issue sidebar (go-gitea#36741)
  Update tool dependencies and fix new lint issues (go-gitea#36702)
  Instance-wide (global) info banner and maintenance mode (go-gitea#36571)
  Add created_by filter to SearchIssues (go-gitea#36670)
  Inline and lazy-load EasyMDE CSS, fix border colors (go-gitea#36714)

# Conflicts:
#	templates/repo/issue/view_content/pull_merge_box.tmpl
#	web_src/js/features/repo-issue-pull.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. 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.

6 participants