From 9bb9a5162311e96f1232de1575247701352646cb Mon Sep 17 00:00:00 2001 From: Giteabot Date: Tue, 20 Oct 2026 12:19:50 -0700 Subject: [PATCH] fix(api): skip label lookup in ListIssues when no labels filter given (#39890) (#39893) Backport #39890 by @SHIVANSHGARG07 strings.Split("", ",") returns []string{""} (length 1), not an empty slice, so the previous len(splitted) > 0 guard was always true and never skipped the label ID lookup, even when the labels query param was absent. Check the raw trimmed param for emptiness before splitting, mirroring the pattern already used elsewhere in this file. Fixes: https://github.com/go-gitea/gitea/issues/39889 Co-authored-by: Shivansh Garg --- routers/api/v1/repo/issue.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 179548d0532..6342f020a74 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -337,8 +337,8 @@ func ListIssues(ctx *context.APIContext) { keyword := ctx.FormTrim("q") var labelIDs []int64 - if splitted := strings.Split(ctx.FormString("labels"), ","); len(splitted) > 0 { - labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx, ctx.Repo.Repository.ID, splitted) + if labelsParam := ctx.FormTrim("labels"); labelsParam != "" { + labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx, ctx.Repo.Repository.ID, strings.Split(labelsParam, ",")) if err != nil { ctx.APIErrorInternal(err) return