api gives "Internal Server Error" when creating a repo with "auto-init" set true #10281

Closed
opened 2025-11-02 09:03:05 -06:00 by GiteaMirror · 11 comments
Owner

Originally created by @brianread108 on GitHub (Feb 16, 2023).

Originally assigned to: @Zettat123 on GitHub.

Description

Using the swagger “Try it out” interface. I keep getting an “505 Internal Server Error” when I try and access /api/v1/user/repos, and use these parameters:

“auto_init”: true,
“default_branch”: “master”,
“description”: “a descr”,
“gitignores”: “”,
“issue_labels”: “”,
“license”: “”,
“name”: “testrepo”,
“private”: false,
“readme”: “Hello World”,
“template”: false,
“trust_model”: “default”

Seems to be the Private parameter. “true” works and “false” gives an internal Server error.
… .and also “auto_init” true gives me the Internal Server Error.

This is our own install of gitea, I can't currently see where on the web interface I can see the version number. I've asked the installer to let me have those details

Gitea Version

1.17.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.31.1

Operating System

Centos 8 (EL8)

How are you running Gitea?

Under proxmox in a Centos 8 VM

I am guessing MYSQL is in use

Database

MySQL

Originally created by @brianread108 on GitHub (Feb 16, 2023). Originally assigned to: @Zettat123 on GitHub. ### Description Using the swagger “Try it out” interface. I keep getting an “505 Internal Server Error” when I try and access /api/v1/user/repos, and use these parameters: “auto_init”: true, “default_branch”: “master”, “description”: “a descr”, “gitignores”: “”, “issue_labels”: “”, “license”: “”, “name”: “testrepo”, “private”: false, “readme”: “Hello World”, “template”: false, “trust_model”: “default” Seems to be the Private parameter. “true” works and “false” gives an internal Server error. … .and also “auto_init” true gives me the Internal Server Error. This is our own install of gitea, I can't currently see where on the web interface I can see the version number. I've asked the installer to let me have those details ### Gitea Version 1.17.3 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.31.1 ### Operating System Centos 8 (EL8) ### How are you running Gitea? Under proxmox in a Centos 8 VM I am guessing MYSQL is in use ### Database MySQL
GiteaMirror added the type/bug label 2025-11-02 09:03:05 -06:00
Author
Owner

@brianread108 commented on GitHub (Feb 16, 2023):

Have updated the version above...

@brianread108 commented on GitHub (Feb 16, 2023): Have updated the version above...
Author
Owner

@lunny commented on GitHub (Feb 16, 2023):

Please paste your logs and if you can test v1.18.3, that's better.

@lunny commented on GitHub (Feb 16, 2023): Please paste your logs and if you can test v1.18.3, that's better.
Author
Owner

@brianread108 commented on GitHub (Feb 16, 2023):

I can switch the repo to public using the update repo api, but would not have expected that to be necessary.

@brianread108 commented on GitHub (Feb 16, 2023): I can switch the repo to public using the update repo api, but would not have expected that to be necessary.
Author
Owner

@brianread108 commented on GitHub (Feb 16, 2023):

Please paste your logs and if you can test v1.18.3, that's better.

I've no idea how to get at the logs, I do not have command level or file level access.

We are looking at updating to 1.18.3.

@brianread108 commented on GitHub (Feb 16, 2023): > Please paste your logs and if you can test v1.18.3, that's better. I've no idea how to get at the logs, I do not have command level or file level access. We are looking at updating to 1.18.3.
Author
Owner

@brianread108 commented on GitHub (Feb 16, 2023):

OK, updated to 1.18.3 and find that the "private" parameter now works to create a public repo. However I still get the failure if I set Auto-init to true.
Screenshot from 2023-02-16 11-51-41

@brianread108 commented on GitHub (Feb 16, 2023): OK, updated to 1.18.3 and find that the "private" parameter now works to create a public repo. However I still get the failure if I set Auto-init to true. ![Screenshot from 2023-02-16 11-51-41](https://user-images.githubusercontent.com/9008937/219358117-857f5ffb-220f-41f5-b32a-18d91e28d302.png)
Author
Owner

@Zettat123 commented on GitHub (Mar 7, 2023):

@brianread108 Maybe the error is caused by “readme”: “Hello World”. Could you please change "Hello World" to "Default" and test again?

@Zettat123 commented on GitHub (Mar 7, 2023): @brianread108 Maybe the error is caused by `“readme”: “Hello World”`. Could you please change "Hello World" to "Default" and test again?
Author
Owner

@brianread108 commented on GitHub (Mar 8, 2023):

curl -X 'POST'
'https://******/api/v1/user/repos'
-H 'accept: application/json'
-H 'Authorization: token *********************************'
-H 'Content-Type: application/json'
-d '{
"auto_init": true,
"default_branch": "master",
"description": "string",
"gitignores": "",
"issue_labels": "",
"license": "",
"name": "Test",
"private": false,
"readme": "default",
"template": false,
"trust_model": "default"
}'

Gives:
Screenshot from 2023-03-08 15-23-23

@brianread108 commented on GitHub (Mar 8, 2023): curl -X 'POST' \ 'https://******/api/v1/user/repos' \ -H 'accept: application/json' \ -H 'Authorization: token *********************************' \ -H 'Content-Type: application/json' \ -d '{ "auto_init": true, "default_branch": "master", "description": "string", "gitignores": "", "issue_labels": "", "license": "", "name": "Test", "private": false, "readme": "default", "template": false, "trust_model": "default" }' Gives: ![Screenshot from 2023-03-08 15-23-23](https://user-images.githubusercontent.com/9008937/223754352-d69c4e33-03e7-4066-b1ee-f3911328167a.png)
Author
Owner

@brianread108 commented on GitHub (Mar 8, 2023):

and:

{
"auto_init": false,
"default_branch": "master",
"description": "string",
"gitignores": "",
"issue_labels": "",
"license": "",
"name": "Test",
"private": false,
"readme": "default",
"template": false,
"trust_model": "default"
}
gives:

Screenshot from 2023-03-08 15-28-47

@brianread108 commented on GitHub (Mar 8, 2023): and: { "auto_init": false, "default_branch": "master", "description": "string", "gitignores": "", "issue_labels": "", "license": "", "name": "Test", "private": false, "readme": "default", "template": false, "trust_model": "default" } gives: ![Screenshot from 2023-03-08 15-28-47](https://user-images.githubusercontent.com/9008937/223755758-1a42507f-23d3-42f8-8759-062453a68b4d.png)
Author
Owner

@jolheiser commented on GitHub (Mar 8, 2023):

I can reproduce on try when using default for the readme, as Default is the correct name and it appears to be case sensitive.

At the very least a 500 isn't correct here, we should be failing more gracefully.

@jolheiser commented on GitHub (Mar 8, 2023): I can reproduce on try when using `default` for the readme, as `Default` is the correct name and it appears to be case sensitive. At the very least a `500` isn't correct here, we should be failing more gracefully.
Author
Owner

@Zettat123 commented on GitHub (Mar 9, 2023):

as Default is the correct name and it appears to be case sensitive

Yes. The "readme" field in request is the name of readme template. The Default template is located in options/readme/Default. User could add new template to custom/options/readme/ to provide new templates for creating repos.

At the very least a 500 isn't correct here, we should be failing more gracefully.

At present, if the specified readme template does not exist, a 500 will be returned. I think a 4xx error would be better and the error message should tell user what templates are available. I will make a PR to improve it.

@Zettat123 commented on GitHub (Mar 9, 2023): > as `Default` is the correct name and it appears to be case sensitive Yes. The `"readme"` field in request is the name of readme template. The Default template is located in `options/readme/Default`. User could add new template to `custom/options/readme/` to provide new templates for creating repos. > At the very least a `500` isn't correct here, we should be failing more gracefully. At present, if the specified readme template does not exist, a `500` will be returned. I think a `4xx` error would be better and the error message should tell user what templates are available. I will make a PR to improve it.
Author
Owner

@brianread108 commented on GitHub (Mar 9, 2023):

Confirming that setting the readme to "Default" works fine and the then auto-init does the job.

Thanks for the help.

@brianread108 commented on GitHub (Mar 9, 2023): Confirming that setting the readme to "Default" works fine and the then auto-init does the job. Thanks for the help.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10281