From 88421bb8885e2e1626f7f2695a2f763c0ea47508 Mon Sep 17 00:00:00 2001 From: Oleksii Zaremskyi Date: Fri, 1 May 2026 16:39:48 +0000 Subject: [PATCH] fix: read --assignee flag value instead of nonexistent --assigned-to (#971) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What this PR does `tea issues list --assignee USERNAME` currently returns every issue regardless of the assignee value — even nonexistent users return a full unfiltered list. Discovered against **tea v0.14.0** (with go-sdk v0.24.1) and reproduced on current `master` (commit `dd81b33`). This PR fixes that. ## Root cause Two distinct bugs on the same flag, both in `cmd/issues/list.go`: 1. **Per-repo path** (`tea issues list --repo OWNER/REPO --assignee USER`): the code reads `ctx.String("assigned-to")` for `AssignedBy`, but the flag is defined as `--assignee` in `cmd/flags/issue_pr.go:66`. The lookup always returns `""`, so the SDK omits the `assigned_by` query parameter and the API returns everything. 2. **Global path** (`tea issues list --assignee USER`, no `--repo`): this hits `/repos/issues/search`, which silently ignores `assigned_by`. Even after fix #1 the no-repo form would still return unfiltered results. Verified directly: - `GET /repos/issues/search?assigned_by=USER&owner=ORG&state=open` → all open issues - `GET /repos/issues/search?assigned=true&owner=ORG&state=open` → only the issues assigned to the authenticated user The endpoint only supports `assigned=true` (boolean self-filter), not arbitrary-user filtering, and `ListIssueOption` doesn't expose that field. Rather than misleading the caller, the no-repo path now returns a clear error. ## Changes Both changes are in `cmd/issues/list.go`: 1. Read `ctx.String("assignee")` instead of the non-existent flag name `"assigned-to"` (lines 80 and 97). 2. In the no-`--repo` branch, return `errors.New("--assignee requires --repo (...)")` when the flag is set. `cmd/pulls/list.go` does not expose an assignee filter, so it's unaffected. The `--author` mapping (`CreatedBy ← ctx.String("author")`) was already correct and is the model the fix follows. ## Manual verification Tested against a local Gitea instance with three open issues (only one assigned to the test user): | Command | Before | After | |---|---|---| | `tea issues list --repo X --assignee me` | all 3 | only the 1 assigned ✓ | | `tea issues list --repo X --assignee nonexistent` | all 3 | `Error: not found` ✓ | | `tea issues list --repo X --author me` | only the 1 (control) | unchanged ✓ | | `tea issues list --assignee me` (no `--repo`) | all 3 (silent) | clear error ✓ | | `tea issues list` (no flags) | all 3 | unchanged ✓ | --------- Co-authored-by: claude_1 Reviewed-on: https://gitea.com/gitea/tea/pulls/971 Reviewed-by: Lunny Xiao Co-authored-by: Oleksii Zaremskyi Co-committed-by: Oleksii Zaremskyi --- cmd/issues/list.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/issues/list.go b/cmd/issues/list.go index 9033f84..4b2652e 100644 --- a/cmd/issues/list.go +++ b/cmd/issues/list.go @@ -5,6 +5,7 @@ package issues import ( stdctx "context" + "errors" "time" "code.gitea.io/tea/cmd/flags" @@ -77,7 +78,7 @@ func RunIssuesList(_ stdctx.Context, cmd *cli.Command) error { Type: kind, KeyWord: ctx.String("keyword"), CreatedBy: ctx.String("author"), - AssignedBy: ctx.String("assigned-to"), + AssignedBy: ctx.String("assignee"), MentionedBy: ctx.String("mentions"), Labels: labels, Milestones: milestones, @@ -88,13 +89,15 @@ func RunIssuesList(_ stdctx.Context, cmd *cli.Command) error { return err } } else { + if ctx.IsSet("assignee") { + return errors.New("--assignee requires --repo (global issue search does not support assignee filter)") + } issues, _, err = ctx.Login.Client().ListIssues(gitea.ListIssueOption{ ListOptions: flags.GetListOptions(cmd), State: state, Type: kind, KeyWord: ctx.String("keyword"), CreatedBy: ctx.String("author"), - AssignedBy: ctx.String("assigned-to"), MentionedBy: ctx.String("mentions"), Labels: labels, Milestones: milestones,