-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
SyntaxError: Unexpected end of JSON input when creating a merge request #31625
Comments
Thanks for your report, are you able to share details of the developer console in your browser, or network tab showing what the http response shows? |
same issue, any solution? |
There were many similar reports: check your reverse-proxy (eg: nginx) & firewall & WAF, do not "deny" some requests for Gitea's backend. If there is still a problem, please show your full configuration (including Gitea's app.ini and your reverse-proxy config), and provide a reproducible setup with detailed steps. |
No WAF and CDN was used, only Nginx was used for reverse proxy. The Nginx configuration is as follows:
|
|
ps: Nginx could have various plugins. , so "please show your full configuration", eg: The config you shown is not the real one you are using, because I can see you manually prettified / changed it. |
This request url is: This request headers is: This response headers is: This response body is null. The full configuration of nginx:
|
I think it is still related to your network or config.
|
I tried using it in the browser's incognito mode, but I still couldn't merge. The complete headers of requests and response are as follows:
We are unable to create a merge request only for this repository. It works fine for all others. |
Try go use other servers than Tencent Cloud. |
We are not using Tencent Cloud servers. |
Then: "please provide a reproducible setup with detailed steps." |
You could provide the reproducible setup by a docker-compose file and some related commands, to make others could also reproduce the problem on their side. |
I received another report similar to this issue. And this time it can indeed be found in Gitea's logs that it received the request and returned a response with zero status code.
IIRC, the framework will return 200 with an empty body if No idea how it could happen, but maybe there is something going wrong with Gitea. |
Fix go-gitea#31625. If `pull_service.NewPullRequest` return an error which misses each `if` check, `CompareAndPullRequestPost` will return immediately, since it doesn't write the HTTP response, a 200 response with empty body will be sent to clients. ```go if err := pull_service.NewPullRequest(ctx, repo, pullIssue, labelIDs, attachments, pullRequest, assigneeIDs); err != nil { if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) { ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error()) } else if git.IsErrPushRejected(err) { // ... ctx.JSONError(flashError) } else if errors.Is(err, user_model.ErrBlockedUser) { // ... ctx.JSONError(flashError) } else if errors.Is(err, issues_model.ErrMustCollaborator) { // ... ctx.JSONError(flashError) } return } ``` Not sure what kind of error can cause it to happen, so this PR just expose it. And we can fix it when users report that creating PRs failed with error responses. It's all my guess since I cannot reproduce the problem, but even if it's not related, the code here needs to be improved.
Backport #31843 by @wolfogre Fix #31625. If `pull_service.NewPullRequest` return an error which misses each `if` check, `CompareAndPullRequestPost` will return immediately, since it doesn't write the HTTP response, a 200 response with empty body will be sent to clients. ```go if err := pull_service.NewPullRequest(ctx, repo, pullIssue, labelIDs, attachments, pullRequest, assigneeIDs); err != nil { if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) { ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error()) } else if git.IsErrPushRejected(err) { // ... ctx.JSONError(flashError) } else if errors.Is(err, user_model.ErrBlockedUser) { // ... ctx.JSONError(flashError) } else if errors.Is(err, issues_model.ErrMustCollaborator) { // ... ctx.JSONError(flashError) } return } ``` Not sure what kind of error can cause it to happen, so this PR just expose it. And we can fix it when users report that creating PRs failed with error responses. It's all my guess since I cannot reproduce the problem, but even if it's not related, the code here needs to be improved. Co-authored-by: Jason Song <[email protected]>
More context and a new clue:
|
Description
When trying to create a merge request in a self-hosted Gitea instance, a toast notification pops up with the message: "SyntaxError: Unexpected end of JSON input". After checking the server logs, no errors were found.
Gitea Version
1.22.0
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Docker, version 20.10.17, running on Ubuntu 22.04.
Database
PostgreSQL
The text was updated successfully, but these errors were encountered: