From 53fe8c26833bd12ceec992ed992cfcd26b054f7e Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Sun, 31 May 2026 05:17:32 +0800 Subject: [PATCH] fix(release): don't clobber latest.json with a 404 "Not Found" body (#4376) The Android and Windows-portable jobs fetched the existing updater manifest with `curl -sL .../latest.json -o latest.json`. Without `-f`, curl writes the server's 404 body ("Not Found") into the file and exits 0, after which `gh release upload --clobber` uploads that invalid JSON as the release's latest.json. tauri-action's updater step then downloads the existing latest.json and runs `JSON.parse(...)` to merge new platforms in. Parsing "Not Found" throws `Unexpected token 'N', "Not Found" is not valid JSON`, failing every build-tauri matrix leg after its bundles were already uploaded. Use `curl -fsSL` so an HTTP error fails the step instead of writing the error body, and validate the download with `jq empty` before merging, so a corrupt manifest can never be clobbered onto the release again. Co-authored-by: Claude Opus 4.8 (1M context) --- .github/workflows/release.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ff1ee0a..c2c51cb9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -273,7 +273,18 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | cd apps/readest-app/ - curl -sL https://github.com/readest/readest/releases/latest/download/latest.json -o latest.json + # Use -f so curl fails on HTTP errors instead of writing the 404 body + # ("Not Found") into latest.json and clobbering the release asset with + # invalid JSON, which then breaks tauri-action's updater merge on every + # subsequent build. + if ! curl -fsSL https://github.com/readest/readest/releases/latest/download/latest.json -o latest.json; then + echo "::error::Failed to download existing latest.json; aborting to avoid clobbering the release asset." + exit 1 + fi + if ! jq empty latest.json 2>/dev/null; then + echo "::error::Existing latest.json is not valid JSON; aborting." + exit 1 + fi version=${{ needs.get-release.outputs.release_version }} universial_apk_url="https://github.com/readest/readest/releases/download/${{ needs.get-release.outputs.release_tag }}/Readest_${version}_universal.apk" @@ -379,7 +390,18 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash run: | - curl -sL https://github.com/readest/readest/releases/latest/download/latest.json -o latest.json + # Use -f so curl fails on HTTP errors instead of writing the 404 body + # ("Not Found") into latest.json and clobbering the release asset with + # invalid JSON, which then breaks tauri-action's updater merge on every + # subsequent build. + if ! curl -fsSL https://github.com/readest/readest/releases/latest/download/latest.json -o latest.json; then + echo "::error::Failed to download existing latest.json; aborting to avoid clobbering the release asset." + exit 1 + fi + if ! jq empty latest.json 2>/dev/null; then + echo "::error::Existing latest.json is not valid JSON; aborting." + exit 1 + fi version=${{ needs.get-release.outputs.release_version }} arch=${{ matrix.config.arch }}