Closed
Description
Description
I am running renovate on my self hosted gitea instance and it fails to get the statuses of a commit if the commit has more statuses than the default limit (requiring renovate to request a second page).
Here are what I believe to be the relevant logs (first group is the successful first request, second group is the failure):
models/auth/token.go:173:GetAccessTokenBySHA() [I] [SQL] SELECT `id`, `uid`, `name`, `token_hash`, `token_salt`, `token_last_eight`, `scope`, `created_unix`, `updated_unix` FROM `access_token` WHERE (token_last_eight = ?) [a152dcca] - 171.416µs
...vices/auth/oauth2.go:145:Verify() [I] [SQL] UPDATE `access_token` SET `uid` = ?, `name` = ?, `token_hash` = ?, `token_salt` = ?, `token_last_eight` = ?, `scope` = ?, `updated_unix` = ? WHERE `id`=? [<redacted>] - 4.416784ms
models/user/user.go:915:GetUserByID() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `is_restricted`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme`, `keep_activity_private` FROM `user` WHERE `id`=? LIMIT 1 [10] - 277.353µs
models/user/user.go:972:GetUserByName() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `is_restricted`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme`, `keep_activity_private` FROM `user` WHERE `lower_name`=? LIMIT 1 [<redacted>] - 185.771µs
[email protected]/engine.go:1246:Get() [I] [SQL] SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `num_projects`, `num_closed_projects`, `num_action_runs`, `num_closed_action_runs`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `git_size`, `lfs_size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `trust_model`, `avatar`, `created_unix`, `updated_unix`, `archived_unix` FROM `repository` WHERE `owner_id`=? AND `lower_name`=? LIMIT 1 [3 <redacted>] - 130.185µs
...epo/collaboration.go:84:IsCollaborator() [I] [SQL] SELECT `id`, `repo_id`, `user_id`, `mode`, `created_unix`, `updated_unix` FROM `collaboration` WHERE `repo_id`=? AND `user_id`=? LIMIT 1 [49 10] - 68.119µs
...ls/repo/repo_unit.go:268:getUnitsByRepoID() [I] [SQL] SELECT `id`, `repo_id`, `type`, `config`, `created_unix` FROM `repo_unit` WHERE (repo_id = ?) [49] - 97.757µs
models/db/context.go:178:GetByBean() [I] [SQL] SELECT `id`, `user_id`, `repo_id`, `mode` FROM `access` WHERE `user_id`=? AND `repo_id`=? LIMIT 1 [10 49] - 55.576µs
...pi/v1/repo/status.go:197:getCommitStatuses() [I] [SQL] SELECT count(*) FROM `commit_status` WHERE (repo_id = ?) AND (sha = ?) LIMIT 30 [49 <redacted>] - 149.412µs
...git/commit_status.go:248:GetCommitStatuses() [I] [SQL] SELECT `id`, `index`, `repo_id`, `state`, `sha`, `target_url`, `description`, `context_hash`, `context`, `creator_id`, `created_unix`, `updated_unix` FROM `commit_status` WHERE (repo_id = ?) AND (sha = ?) ORDER BY `created_unix` DESC LIMIT 30 [49 <redacted>] - 150.464µs
models/repo/repo.go:779:GetRepositoryByID() [I] [SQL] SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `num_projects`, `num_closed_projects`, `num_action_runs`, `num_closed_action_runs`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `git_size`, `lfs_size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `trust_model`, `avatar`, `created_unix`, `updated_unix`, `archived_unix` FROM `repository` WHERE `id`=? LIMIT 1 [49] - 653.254µs
models/user/user.go:915:GetUserByID() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `is_restricted`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme`, `keep_activity_private` FROM `user` WHERE `id`=? LIMIT 1 [3] - 125.167µs
models/auth/token.go:173:GetAccessTokenBySHA() [I] [SQL] SELECT `id`, `uid`, `name`, `token_hash`, `token_salt`, `token_last_eight`, `scope`, `created_unix`, `updated_unix` FROM `access_token` WHERE (token_last_eight = ?) [<redacted>] - 157.565µs
...vices/auth/oauth2.go:145:Verify() [I] [SQL] UPDATE `access_token` SET `uid` = ?, `name` = ?, `token_hash` = ?, `token_salt` = ?, `token_last_eight` = ?, `scope` = ?, `updated_unix` = ? WHERE `id`=? [<redacted>] - 6.455588ms
models/user/user.go:915:GetUserByID() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `is_restricted`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme`, `keep_activity_private` FROM `user` WHERE `id`=? LIMIT 1 [10] - 155.729µs
models/user/user.go:972:GetUserByName() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `is_restricted`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme`, `keep_activity_private` FROM `user` WHERE `lower_name`=? LIMIT 1 [<redacted>] - 125.594µs
[email protected]/engine.go:1246:Get() [I] [SQL] SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `num_projects`, `num_closed_projects`, `num_action_runs`, `num_closed_action_runs`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `git_size`, `lfs_size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `trust_model`, `avatar`, `created_unix`, `updated_unix`, `archived_unix` FROM `repository` WHERE `owner_id`=? AND `lower_name`=? LIMIT 1 [3 <redacted>] - 94.56µs
...epo/collaboration.go:84:IsCollaborator() [I] [SQL] SELECT `id`, `repo_id`, `user_id`, `mode`, `created_unix`, `updated_unix` FROM `collaboration` WHERE `repo_id`=? AND `user_id`=? LIMIT 1 [49 10] - 62.068µs
...ls/repo/repo_unit.go:268:getUnitsByRepoID() [I] [SQL] SELECT `id`, `repo_id`, `type`, `config`, `created_unix` FROM `repo_unit` WHERE (repo_id = ?) [49] - 103.589µs
models/db/context.go:178:GetByBean() [I] [SQL] SELECT `id`, `user_id`, `repo_id`, `mode` FROM `access` WHERE `user_id`=? AND `repo_id`=? LIMIT 1 [10 49] - 28.62µs
...pi/v1/repo/status.go:197:getCommitStatuses() [I] [SQL] SELECT count(*) FROM `commit_status` WHERE (repo_id = ?) AND (sha = ?) LIMIT 30 OFFSET 30 [49 <redacted>] - 133.356µs
...git/commit_status.go:240:GetCommitStatuses() [E] Count PRs: sql: no rows in result set
...pi/v1/repo/status.go:203:getCommitStatuses() [E] GetCommitStatuses: GetCommitStatuses[<redacted>, <redacted>, 2]: sql: no rows in result set
...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/repos/<redacted>/<redacted>/commits/<redacted>/statuses?page=2 for 162.158.111.145:0, 500 Internal Server Error in 56.1ms @ repo/status.go:129(repo.GetCommitStatusesByRef)
It looks like the SQL command is applying the OFFSET of the page to the final count rather than the actual query.
gitea/models/git/commit_status.go
Lines 237 to 239 in 669bbba
The renovate error message (which I don't think is necessary, as I believe it is doing what it should) is:
{
"name": "HTTPError",
"code": "ERR_NON_2XX_3XX_RESPONSE",
"timings": {
"start": 1704979100676,
"socket": 1704979100677,
"lookup": 1704979100678,
"connect": 1704979100680,
"secureConnect": 1704979100686,
"upload": 1704979100686,
"response": 1704979100765,
"end": 1704979100765,
"phases": {
"wait": 1,
"dns": 1,
"tcp": 2,
"tls": 6,
"request": 0,
"firstByte": 79,
"download": 0,
"total": 89
}
},
"message": "Response code 500 (Internal Server Error)",
"stack": "HTTPError: Response code 500 (Internal Server Error)\n at Request.<anonymous> (/opt/containerbase/tools/renovate/37.128.4/node_modules/got/dist/source/as-promise/index.js:118:42)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)",
"options": {
"headers": {
"user-agent": "RenovateBot/37.128.4 (https://github.com/renovatebot/renovate)",
"accept": "application/json",
"authorization": "***********",
"accept-encoding": "gzip, deflate, br"
},
"url": "https://<redacted>/api/v1/repos/<redacted>/<redacted>/commits/<redacted>/statuses?page=2",
"hostType": "gitea",
"username": "",
"password": "",
"method": "GET",
"http2": false
},
"response": {
"statusCode": 500,
"statusMessage": "Internal Server Error",
"body": {
"message": "",
"url": "https://<redacted>/api/swagger"
},
"headers": {
"date": "Thu, 11 Jan 2024 13:18:20 GMT",
"content-type": "application/json;charset=utf-8",
"content-length": "55",
"connection": "close",
"cache-control": "max-age=0, private, must-revalidate, no-transform",
"x-content-type-options": "nosniff",
"x-frame-options": "SAMEORIGIN",
"cf-cache-status": "DYNAMIC",
"nel": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}",
"server": "cloudflare",
"alt-svc": "h3=\":443\"; ma=86400"
},
"httpVersion": "1.1",
"retryCount": 2
}
}
Gitea Version
1.21.3
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
2.43.0
Operating System
Linux Ubuntu 23.10
How are you running Gitea?
Official binary
Database
SQLite