Skip to content

PR comment causes 500 server error #7113

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

Closed
1 of 7 tasks
otbutz opened this issue Jun 3, 2019 · 5 comments
Closed
1 of 7 tasks

PR comment causes 500 server error #7113

otbutz opened this issue Jun 3, 2019 · 5 comments
Labels
issue/duplicate The issue has already been reported.

Comments

@otbutz
Copy link

otbutz commented Jun 3, 2019

  • Gitea version (or commit ref): 1.8.1
  • Git version: 2.21
  • Operating system: Ubuntu 18.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:
2019/06/03 07:48:37 [.../repo/pull_review.go:80 CreateCodeComment()] [E] CreateCodeComment: pq: invalid byte sequence for encoding "UTF8": 0xb3

Description

No matter which file i'm trying to comment in this particular PR, the same error happens. Simply writing test in the comment generates the same issue.

@zeripath
Copy link
Contributor

zeripath commented Jun 3, 2019

I suspect the issue is that the underlying code line and Patch component here is not UTF-8:

return CreateComment(&CreateCommentOptions{
Type: CommentTypeCode,
Doer: doer,
Repo: repo,
Issue: issue,
Content: content,
LineNum: line,
TreePath: treePath,
CommitSHA: commitID,
ReviewID: reviewID,
Patch: patch,
})

@zeripath
Copy link
Contributor

zeripath commented Jun 3, 2019

OK looking at:

patchBuf := new(bytes.Buffer)
if err := GetRawDiffForFile(gitRepo.Path, pr.MergeBase, headCommitID, RawDiffNormal, treePath, patchBuf); err != nil {
return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", err, gitRepo.Path, pr.MergeBase, headCommitID, treePath)
}
patch = CutDiffAroundLine(strings.NewReader(patchBuf.String()), int64((&Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)

The issue is that patchBuf.String() doesn't actually guarantee that the String is a valid UTF-8 string. (Thanks Go(!)) Git diff gives you the raw bytes - it doesn't care about the encoding.

@zeripath
Copy link
Contributor

zeripath commented Jun 3, 2019

@otbutz is there any chance you could upload a minimal test file to try.gitea.io it would be nice to know which encoding breaks this.

@otbutz
Copy link
Author

otbutz commented Jun 3, 2019

Not really. Corporate project.

@lafriks
Copy link
Member

lafriks commented Jun 7, 2019

Duplicate of #6236

@lafriks lafriks marked this as a duplicate of #6236 Jun 7, 2019
@lafriks lafriks added the issue/duplicate The issue has already been reported. label Jun 7, 2019
@lafriks lafriks closed this as completed Jun 7, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/duplicate The issue has already been reported.
Projects
None yet
Development

No branches or pull requests

3 participants