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 gives "Internal Server Error" when creating a repo with "auto-init" set true #22934

Closed
brianread108 opened this issue Feb 16, 2023 · 11 comments · Fixed by #23387
Closed

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

brianread108 opened this issue Feb 16, 2023 · 11 comments · Fixed by #23387
Assignees
Labels

Comments

@brianread108
Copy link

brianread108 commented Feb 16, 2023

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

@brianread108
Copy link
Author

Have updated the version above...

@lunny
Copy link
Member

lunny commented Feb 16, 2023

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

@brianread108
Copy link
Author

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

@brianread108
Copy link
Author

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
Copy link
Author

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 brianread108 changed the title api gives "Internal Server Error" when creating a repo api gives "Internal Server Error" when creating a repo with "auto-init" set true Feb 21, 2023
@Zettat123 Zettat123 self-assigned this Mar 7, 2023
@Zettat123
Copy link
Contributor

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

@Zettat123 Zettat123 added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Mar 7, 2023
@brianread108
Copy link
Author

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
Copy link
Author

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

@jolheiser
Copy link
Member

jolheiser commented 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.

@Zettat123
Copy link
Contributor

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 Zettat123 removed the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Mar 9, 2023
@brianread108
Copy link
Author

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

Thanks for the help.

jolheiser pushed a commit that referenced this issue Mar 13, 2023
Close #22934 

In `/user/repos` API (and other APIs related to creating repos), user
can specify a readme template for auto init. At present, if the
specified template does not exist, a `500` will be returned . This PR
improved the logic and will return a `400` instead of `500`.
Zettat123 added a commit to Zettat123/gitea that referenced this issue Mar 16, 2023
Close go-gitea#22934

In `/user/repos` API (and other APIs related to creating repos), user
can specify a readme template for auto init. At present, if the
specified template does not exist, a `500` will be returned . This PR
improved the logic and will return a `400` instead of `500`.
Zettat123 added a commit to Zettat123/gitea that referenced this issue Mar 16, 2023
Close go-gitea#22934

In `/user/repos` API (and other APIs related to creating repos), user
can specify a readme template for auto init. At present, if the
specified template does not exist, a `500` will be returned . This PR
improved the logic and will return a `400` instead of `500`.
techknowlogick added a commit that referenced this issue Mar 17, 2023
Backport #23387 
Close #22934

In `/user/repos` API (and other APIs related to creating repos), user
can specify a readme template for auto init. At present, if the
specified template does not exist, a `500` will be returned . This PR
improved the logic and will return a `400` instead of `500`.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
techknowlogick pushed a commit that referenced this issue Mar 17, 2023
Backport #23387 
Close #22934

In `/user/repos` API (and other APIs related to creating repos), user
can specify a readme template for auto init. At present, if the
specified template does not exist, a `500` will be returned . This PR
improved the logic and will return a `400` instead of `500`.
@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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants