Skip to content

Report HTTP status in Gitea/Forgejo API errors - #167

Open
andrew wants to merge 1 commit into
mainfrom
gitea-release-errors
Open

andrew wants to merge 1 commit into
mainfrom
gitea-release-errors

Conversation

@andrew

@andrew andrew commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

The Gitea SDK's error handling reads only the message field from the response body and discards the HTTP status. Forgejo returns two responses that make this useless:

  • 409 {"message":"Release has no Tag"} when a release already exists for the tag (the wording refers to an internal is_tag column, not the git tag)
  • 500 {"message":""} for anything that reaches a catch-all branch, since Forgejo blanks 500 messages for non-admins in production

so forge release create printed Error: Release has no Tag or a bare Error: respectively, and any other endpoint that hit a 500 did the same.

Add a wrapErr(op, resp, err) helper that includes the operation name and resp.Status, and route every SDK error in the gitea backend through it. 404 still maps to forge.ErrNotFound, and the ErrOwnerNotFound/ErrLabelExists special cases are preserved. The release-create 409 is mapped to release for tag "v1.0.0" already exists.

Fixes #166

Copilot AI lite review requested due to automatic review settings September 24, 2026 16:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The Gitea SDK returns errors containing only the server's message
field, which Forgejo blanks on 500s in production and which is
sometimes cryptic (409 'Release has no Tag' means a release already
exists). Add a wrapErr helper that includes the operation name and
HTTP status, apply it across the gitea backend, and map the
release-create 409 to a message that says what happened.

Fixes #166
@andrew
andrew force-pushed the gitea-release-errors branch from d6cf915 to 272b029 Compare September 24, 2026 16:37
@andrew andrew changed the title Report HTTP status in Gitea release errors Report HTTP status in Gitea/Forgejo API errors Sep 24, 2026
@defect-track

Copy link
Copy Markdown

wow, didn't expect such a big PR...

Hope I can get it tested over the weekend. Doesn't take to much for me to reproduce.

Appreciate your quick turn around

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

forge release create produces unhelpful/generic error messages that make debugging release failures nearly impossible (Forgejo)

3 participants