mirror of
https://github.com/go-gitea/gitea.git
synced 2026-02-22 15:25:05 +01:00
When NewComment's CreateIssueComment call failed, ctx.ServerError wrote an HTML 500 page but the deferred function still ran and appended a JSON redirect to the response body, producing an invalid mixed HTML+JSON response shown as a toast error. Fix by adding a ctx.Written() guard in the defer to skip writing when a response was already sent. Also make post-creation errors in CreateIssueComment (FindAndUpdateIssueMentions, GetIssueByID) non-fatal since the comment is already persisted at that point, preventing duplicate comments on retry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>