PR comment causes 500 server error #3418

Closed
opened 2025-11-02 05:12:21 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @otbutz on GitHub (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.

Originally created by @otbutz on GitHub (Jun 3, 2019). - Gitea version (or commit ref): 1.8.1 - Git version: 2.21 - Operating system: Ubuntu 18.04 - Database (use `[x]`): - [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.
GiteaMirror added the issue/duplicate label 2025-11-02 05:12:21 -06:00
Author
Owner

@zeripath commented on GitHub (Jun 3, 2019):

I suspect the issue is that the underlying code line and Patch component here is not UTF-8: 45f588e85d/models/issue_comment.go (L928-L939)

@zeripath commented on GitHub (Jun 3, 2019): I suspect the issue is that the underlying code line and Patch component here is not UTF-8: https://github.com/go-gitea/gitea/blob/45f588e85dbd3004334718dc9fbbb27675814ee0/models/issue_comment.go#L928-L939
Author
Owner

@zeripath commented on GitHub (Jun 3, 2019):

OK looking at:

45f588e85d/models/issue_comment.go (L922-L926)

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 commented on GitHub (Jun 3, 2019): OK looking at: https://github.com/go-gitea/gitea/blob/45f588e85dbd3004334718dc9fbbb27675814ee0/models/issue_comment.go#L922-L926 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.
Author
Owner

@zeripath commented on GitHub (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.

@zeripath commented on GitHub (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.
Author
Owner

@otbutz commented on GitHub (Jun 3, 2019):

Not really. Corporate project.

@otbutz commented on GitHub (Jun 3, 2019): Not really. Corporate project.
Author
Owner

@lafriks commented on GitHub (Jun 7, 2019):

Duplicate of #6236

@lafriks commented on GitHub (Jun 7, 2019): Duplicate of #6236
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3418