Anything an API customer should know beyond "Not Found" #7753

Closed
opened 2025-11-02 07:35:29 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @vw98075 on GitHub (Aug 26, 2021).

  • Gitea version (or commit ref): 1.15.0
  • Git version:
  • Operating system:
  • Database (use [x]):
    • [x ] PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:

Description

For an API request, on the Gitea console,

2021/08/25 21:06:30 Started POST /api/v1/repos/gitea-admin/java-code-template/generate for 127.0.0.1:54184
2021/08/25 21:06:30 Completed POST /api/v1/repos/gitea-admin/java-code-template/generate 404 Not Found in 5.61183ms

On a client app console

2021-08-25 21:06:30.540 DEBUG 97801 --- [  XNIO-1 task-2] c.i.c.reposetup.web.rest.GiteaResource   : GenerateRepoOption{avatar=true, description='null', gitContent=true, gitHooks=true, labels=true, name='al14ce735-java', owner='al14ce735', _private=true, topics=true, webhooks=true}
2021-08-25 21:06:30.541 DEBUG 97801 --- [  XNIO-1 task-2] c.i.c.reposetup.web.rest.GiteaResource   : {"avatar":true,"git_content":true,"git_hooks":true,"labels":true,"name":"al14ce735-java","owner":"al14ce735","private":true,"topics":true,"webhooks":true}
2021-08-25 21:06:30.547 ERROR 97801 --- [  XNIO-1 task-2] c.i.c.reposetup.web.rest.GiteaResource   : Response{protocol=http/1.1, code=404, message=Not Found, url=http://localhost:3000/api/v1/repos/gitea-admin/java-code-template/generate}

This request is submitted by the user "gitea-admin" and the user is an admin user.

For the error message "Not Found" without any further explanation in neither the Gitea log nor the response message, logical thinking would be one or more entities referred to in the REST request could not be found in the Gitea. Those entities referred to in the request are that the username in the request body, the username and template name in the request path. So, I run the following two queries on the Gitea DB.

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, is_private, is_empty, is_archived, is_mirror, status, is_fork, fork_id, is_template, template_id, size, is_fsck_enabled, close_issues_via_commit_in_any_branch, topics, trust_model, avatar, created_unix, updated_unix
	FROM public.repository
	where owner_name ='gitea-admin' and name='java-code-template';

and

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 public."user"
	where name='al14ce735';

Both return an entry.

Please advise how an API customer figures out the cause of the request error based on a simple error message, "Not Found".

Screenshots

Originally created by @vw98075 on GitHub (Aug 26, 2021). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq) 5. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.15.0 - Git version: - Operating system: <!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package --> <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> - Database (use `[x]`): - [x ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - Log gist: <!-- It really is important to provide pertinent logs --> <!-- Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems --> <!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini --> ## Description <!-- If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please disable the proxy/CDN fully and connect to gitea directly to confirm the issue still persists without those services. --> For an API request, on the Gitea console, ``` 2021/08/25 21:06:30 Started POST /api/v1/repos/gitea-admin/java-code-template/generate for 127.0.0.1:54184 2021/08/25 21:06:30 Completed POST /api/v1/repos/gitea-admin/java-code-template/generate 404 Not Found in 5.61183ms ``` On a client app console ``` 2021-08-25 21:06:30.540 DEBUG 97801 --- [ XNIO-1 task-2] c.i.c.reposetup.web.rest.GiteaResource : GenerateRepoOption{avatar=true, description='null', gitContent=true, gitHooks=true, labels=true, name='al14ce735-java', owner='al14ce735', _private=true, topics=true, webhooks=true} 2021-08-25 21:06:30.541 DEBUG 97801 --- [ XNIO-1 task-2] c.i.c.reposetup.web.rest.GiteaResource : {"avatar":true,"git_content":true,"git_hooks":true,"labels":true,"name":"al14ce735-java","owner":"al14ce735","private":true,"topics":true,"webhooks":true} 2021-08-25 21:06:30.547 ERROR 97801 --- [ XNIO-1 task-2] c.i.c.reposetup.web.rest.GiteaResource : Response{protocol=http/1.1, code=404, message=Not Found, url=http://localhost:3000/api/v1/repos/gitea-admin/java-code-template/generate} ``` This request is submitted by the user "gitea-admin" and the user is an admin user. For the error message "Not Found" without any further explanation in neither the Gitea log nor the response message, logical thinking would be one or more entities referred to in the REST request could not be found in the Gitea. Those entities referred to in the request are that the username in the request body, the username and template name in the request path. So, I run the following two queries on the Gitea DB. ``` 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, is_private, is_empty, is_archived, is_mirror, status, is_fork, fork_id, is_template, template_id, size, is_fsck_enabled, close_issues_via_commit_in_any_branch, topics, trust_model, avatar, created_unix, updated_unix FROM public.repository where owner_name ='gitea-admin' and name='java-code-template'; ``` and ``` 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 public."user" where name='al14ce735'; ``` Both return an entry. Please advise how an API customer figures out the cause of the request error based on a simple error message, "Not Found". ## Screenshots <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/question label 2025-11-02 07:35:29 -06:00
Author
Owner

@zeripath commented on GitHub (Aug 26, 2021):

The reason we return 404 and no other information is simple: If the base repository that a user is trying to get to is private or otherwise hidden we have to return 404 not found otherwise we reveal the presence of the repo and leak that data.

@zeripath commented on GitHub (Aug 26, 2021): The reason we return 404 and no other information is simple: If the base repository that a user is trying to get to is private or otherwise hidden we have to return 404 not found otherwise we reveal the presence of the repo and leak that data.
Author
Owner

@vw98075 commented on GitHub (Aug 26, 2021):

The template repo isn't private. The whole repo setup can be found in those three screenshots. Please advise anything would prevent the API call.
Screen Shot 2021-08-26 at 9 12 58 AM
Screen Shot 2021-08-26 at 9 11 55 AM
Screen Shot 2021-08-26 at 9 09 20 AM

@vw98075 commented on GitHub (Aug 26, 2021): The template repo isn't private. The whole repo setup can be found in those three screenshots. Please advise anything would prevent the API call. <img width="868" alt="Screen Shot 2021-08-26 at 9 12 58 AM" src="https://user-images.githubusercontent.com/10793038/130998326-5a5e8ec8-8440-4e73-a08c-d5bf8b802155.png"> <img width="868" alt="Screen Shot 2021-08-26 at 9 11 55 AM" src="https://user-images.githubusercontent.com/10793038/130998333-eebcb152-c990-4a75-90c6-5883e452b72c.png"> <img width="868" alt="Screen Shot 2021-08-26 at 9 09 20 AM" src="https://user-images.githubusercontent.com/10793038/130998338-572230c0-4508-4f29-a376-e74fcd0871ce.png">
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7753