forgejo/models/repo
forgejo-backport-action 0403a38217 [v15.0/forgejo] fix: make /repos/search?uid=-2 return zero results, no repos with that owner (#12150)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/12144

API calls to `.../api/v1/repos/search?uid=-2&archived=false` currently do not apply the filter `uid` because of the negative value.  This can occur when APIs are interacting with `${{ forgejo.token }}` and believe they're operating as the Forgejo Actions user, which has UID -2.

In combination with the security checks that occur in the `/repos/search` API to validate that repositories accessed are visible to the user, this can result in 500 error responses when a more correct expectation would be to receive no repositories:

da8898822c/routers/api/v1/repo/repo.go (L237-L242)

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. All work and communication must conform to Forgejo's [AI Agreement](https://codeberg.org/forgejo/governance/src/branch/main/AIAgreement.md). There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests for Go changes

- I added test coverage for Go changes...
  - [ ] in their respective `*_test.go` for unit tests.
  - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I ran...
  - [x] `make pr-go` before pushing

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.

Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12150
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
2026-04-16 21:00:50 +02:00
..
fixtures/TestFindRepoAttachmentsByUUID chore: add unit test 2026-03-06 11:21:07 -07:00
TestGetUserForkLax fix: reduce deadlocks merging PRs by using caching for repo issue count stats (#9922) 2025-10-31 23:50:05 +01:00
TestGetUserForkLaxWithTwoChoices fix: reduce deadlocks merging PRs by using caching for repo issue count stats (#9922) 2025-10-31 23:50:05 +01:00
TestSearchRepositoryIDsByCondition fix: reduce deadlocks merging PRs by using caching for repo issue count stats (#9922) 2025-10-31 23:50:05 +01:00
archive_download_count.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
archive_download_count_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
archiver.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
attachment.go fix: check that attachments belong to correct resource 2026-03-06 11:21:07 -07:00
attachment_test.go chore: add unit test 2026-03-06 11:21:07 -07:00
authz.go refactor: split AuthorizationReducer into a base RepositoryAuthorizationReducer interface 2026-03-01 17:05:53 +01:00
avatar.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
collaboration.go feat: add foreign keys to table collaboration (#9724) 2025-10-18 02:50:50 +02:00
collaboration_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
following_repo.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
following_repo_test.go chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
fork.go feat: allow PRs between common forks of the same base repository (#9045) 2025-10-01 04:58:12 +02:00
fork_test.go feat: allow PRs between common forks of the same base repository (#9045) 2025-10-01 04:58:12 +02:00
git.go feat: introduce global merge message templates (#8347) 2025-07-12 16:00:42 +02:00
issue.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
language_stats.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
language_stats_test.go chore: remove usages of sort.Sort (#6689) 2025-01-26 13:30:00 +00:00
main_test.go chore: move all test blank imports in a single package (#10662) 2026-01-02 05:32:32 +01:00
mirror.go [v15.0/forgejo] fix: store pull mirror creds encrypted with keying (#11984) 2026-04-04 14:47:05 +02:00
moderation.go feat: render a link to poster profile next to the ID within shadow copy details (#10194) 2025-12-09 15:19:10 +01:00
moderation_test.go feat: Admin interface for abuse reports (#7905) 2025-07-23 00:20:15 +02:00
pushmirror.go feat: cache derived keys for faster keying (#10114) 2025-11-16 14:29:14 +01:00
pushmirror_test.go feat: add configuration to only push mirror selected branches (#7823) 2025-07-12 00:39:35 +02:00
redirect.go fix: do permission check for repository redirect 2025-08-30 09:37:34 +02:00
redirect_test.go fix: do permission check for repository redirect 2025-08-30 09:37:34 +02:00
release.go fix: check that attachments belong to correct resource 2026-03-06 11:21:07 -07:00
release_list.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
release_list_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
release_test.go feat: add tag label to commit list view (#8759) 2025-08-06 14:47:51 +02:00
repo.go [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
repo_flags.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
repo_flags_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
repo_indexer.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
repo_list.go [v15.0/forgejo] fix: make /repos/search?uid=-2 return zero results, no repos with that owner (#12150) 2026-04-16 21:00:50 +02:00
repo_list_test.go feat(ui): create repo-specific access tokens (#11696) 2026-03-23 15:29:08 +01:00
repo_repository.go fix: assorted ActivityPub code only refactors (#8708) 2025-07-28 15:17:29 +02:00
repo_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
repo_unit.go [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
repo_unit_test.go fix: corrupted wiki unit default permission (#8234 follow-up) (#8258) 2025-07-07 18:04:00 +02:00
search.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
star.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
star_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
topic.go chore(api): update swagger method descripitons (#8728) 2025-07-30 18:08:28 +02:00
topic_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
update.go chore: remove redundant code (#9378) 2025-09-22 09:18:19 +02:00
update_test.go chore: remove redundant code (#9378) 2025-09-22 09:18:19 +02:00
upload.go [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
user_repo.go feat: implement fine-grained access tokens in /user/subscriptions & /users/{username}/subscriptions 2026-03-01 17:05:53 +01:00
user_repo_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
watch.go fix: decrease watch count when blocking user (#10882) 2026-01-26 22:58:22 +01:00
watch_test.go chore: remove dead code in WatchIfAuto and general model documentation (#10880) 2026-01-26 12:03:08 +01:00
wiki.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
wiki_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00