Repository navigation
fix(hvcs-gitea): raise AssetUploadError when release asset uploads fail - #1516
Open
qianeric-backup wants to merge 1 commit into
Open
qianeric-backup wants to merge 1 commit into
qianeric-backup wants to merge 1 commit into
Conversation
Gitea.upload_dists() logs an HTTPError and moves on, so when every asset fails to upload it returns 0 and `semantic-release publish` exits 0 -- a release with nothing attached reports as successful. GitHub.upload_dists() does the same job and collects the failures into an AssetUploadError, which publish.py already turns into a non-zero exit. This copies that body, so the two backends behave the same.
qianeric-backup
marked this pull request as ready for review
November 27, 2026 06:36
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Gitea.upload_dists()reports success when every asset upload failed.except HTTPError:logs the failure and moves on, so the returned count is just "how many worked". When all of them fail it returns0,publish_distributions()ignores the count, andsemantic-release publishexits 0. CI reads that as a successful release while nothing was attached to it.Rationale
GitHub.upload_dists()does the same job and gets it right. The two methods are otherwise line-for-line the same, sodiff -uofgithub.py:458-486againstgitea.py:318-335has exactly one functional difference, and it is this one: GitHub collects the failed(file, status)pairs and ends withgitea.pyalready importsAssetUploadError(line 16) and already raises it on the analogous path inGitea.create_release():so the swallow looks like an omission rather than a deliberate choice.
semantic-release/cli/commands/publish.py:101already handles it:The change copies the GitHub body verbatim, which also means a partial failure now reports which assets failed and with what status instead of silently attaching some of them:
Nothing about a successful upload changes —
n_succeededis still returned, and a release that doesn't exist still logs the warning and returns0, matching the other backend.How did you test?
New tests in
tests/unit/semantic_release/hvcs/test_gitea.py:test_upload_dists_fails_with_http_error(parametrized over 429/500/503 — all assets fail,AssetUploadErrorraised, message names the file and the status) andtest_upload_dists_partial_failure(one success, one failure — still raises, and the count is not reported as success).masterwith only the tests added:8 failed, 23 passed31 passed4293 passed, 1 failedbefore and after;comm -3of theFAILEDlines differs only by the new test ids. The one pre-existing failure istest_toml_declaration_from_definition[Default number format for project.version], a localtomlkitversion difference, present on both trees.--noop, the four URL builders, owner/repo parsing) produce byte-identical output before and after.ruff==0.6.1(the pin inuv.lock):ruff checkandruff format --checkclean, on both trees.No AI assistance was used to write the tests' expectations; the assertions were read off the existing
test_github.pyequivalents so the two backends are checked the same way.