Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Search Issues, dont show 500 if filter result in empty list #19244

Merged
merged 8 commits into from
Apr 8, 2022

Conversation

6543
Copy link
Member

@6543 6543 commented Mar 28, 2022

as title

@6543 6543 added type/bug modifies/api This PR adds API routes or modifies them backport/v1.16 labels Mar 28, 2022
@6543 6543 added this to the 1.17.0 milestone Mar 28, 2022
@lunny
Copy link
Member

lunny commented Mar 29, 2022

But at least we need to know there is a bug there.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 29, 2022
Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

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

@lunny I have no idea why it should be an error that no issue matched the filter.
The combination of returning no error and 0 should be hint enough for that.

@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 Mar 29, 2022
models/issue.go Outdated Show resolved Hide resolved
@6543
Copy link
Member Author

6543 commented Mar 29, 2022

But at least we need to know there is a bug there.

I would also consider a filter that is to restrictive and so return 0 not an error

models/issue.go Outdated Show resolved Hide resolved
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

Need to be improved in my mind.

  1. the sql select count(t1.id) from t1 inner join t2 on t1.id=t2.id always return 1 rows with a column value 0 or 123.
  2. why the Find result becomes 0 rows, I think it's a bug caused by opts.Page>0, then there is a limit 10,20 in the sql, or maybe something else related to limit. How it happens? Is it correct?
  3. the RepoID int64 in countsSlice struct seems useless (and incorrect .... there is no such column in result)

Since we are fixing bugs, I think if there is a chance, we should fix the root case.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Mar 30, 2022

I proposed a full fix: use setupSessionNoLimit instead of setupSessionWithLimit when no pagination

wxiaoguang@18aeedf

There are 4 functions need to call setupSession: three of them CountIssues/CountIssuesByRepo/GetRepoIDsForIssuesOptions shouldn't use limit, only Issues() need the limit. And fine tuned the errors with wrapper.

@wxiaoguang
Copy link
Contributor

I think we can have this fix in 1.16.6 since it's a bug.

@6543
Copy link
Member Author

6543 commented Apr 7, 2022

Ok let me cherrypick merge

@6543 6543 requested a review from wxiaoguang April 7, 2022 22:11
@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 Apr 8, 2022
@6543 6543 merged commit 75f8534 into go-gitea:main Apr 8, 2022
@6543 6543 deleted the fix-500-on-issue-search-no-items branch April 8, 2022 02:39
Codeberg-org pushed a commit to Codeberg-org/gitea that referenced this pull request Apr 8, 2022
…gitea#19244)

* remove error who is none

* use setupSessionNoLimit instead of setupSessionWithLimit when no pagination

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 11, 2022
* giteaofficial/main: (22 commits)
  Add logic to switch between source/rendered on Markdown (go-gitea#19356)
  Fixed registry host value. (go-gitea#19363)
  [skip ci] Updated translations via Crowdin
  Allow package linking to private repository (go-gitea#19348)
  Use "main" as default branch name (go-gitea#19354)
  Move milestone to models/issues/ (go-gitea#19278)
  Refactor CSRF protection modules, make sure CSRF tokens can be up-to-date. (go-gitea#19337)
  Remove dependent on session auth for api/v1 routers (go-gitea#19321)
  API: Search Issues, dont show 500 if filter result in empty list (go-gitea#19244)
  [skip ci] Updated translations via Crowdin
  Never use /api/v1 from Gitea UI Pages (go-gitea#19318)
  [skip ci] Updated translations via Crowdin
  Show ssh command directly in template instead of i18n translation (go-gitea#19335)
  Package registry changes (go-gitea#19305)
  [skip ci] Updated translations via Crowdin
  Add `ENABLE_SSH_LOG` to debugging problems (go-gitea#19316)
  Warn on SSH connection for incorrect configuration (go-gitea#19317)
  escape fake link
  Allow custom redirect for landing page (go-gitea#19324)
  [skip ci] Updated translations via Crowdin
  ...
6543 added a commit to 6543-forks/gitea that referenced this pull request Apr 20, 2022
…gitea#19244)

* remove error who is none

* use setupSessionNoLimit instead of setupSessionWithLimit when no pagination

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@6543 6543 added the backport/done All backports for this PR have been created label Apr 20, 2022
6543 added a commit that referenced this pull request Apr 20, 2022
) (#19436)

Backport #19244

* remove error who is none

* use setupSessionNoLimit instead of setupSessionWithLimit when no pagination

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this pull request Aug 24, 2022
…gitea#19244)

* remove error who is none

* use setupSessionNoLimit instead of setupSessionWithLimit when no pagination

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created 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 type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants