From a1f5016f02b4ef9870ca8d6a1e3c69af3203f1ec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 17:42:24 +0000 Subject: [PATCH] Add proper error handling for empty file list and preserve filepath integrity Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --- .github/workflows/nightly.yml | 40 +++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e774a9701..be467bf3e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -720,12 +720,14 @@ jobs: # Read NUL-delimited input with open("release_files.txt", "rb") as f: content = f.read() + + # Handle empty file case explicitly + if content.rstrip(b"\0"): # Strip trailing NUL before splitting to avoid empty trailing element - files = content.decode("utf-8").rstrip("\0").split("\0") if content else [] + files = content.decode("utf-8").rstrip("\0").split("\0") for filepath in files: - filepath = filepath.strip() - if not filepath: + if not filepath: # Skip empty strings continue basename = os.path.basename(filepath) @@ -735,7 +737,7 @@ jobs: seen_basenames.add(basename) unique_files.append(filepath) - # Write NUL-delimited output + # Write NUL-delimited output with trailing NUL with open("release_files_dedup.txt", "wb") as f: if unique_files: f.write("\0".join(unique_files).encode("utf-8")) @@ -743,18 +745,24 @@ jobs: DEDUP_SCRIPT # Read files into bash array safely using NUL delimiter - declare -a FILES - while IFS= read -r -d $'\0' file; do - FILES+=("$file") - done < release_files_dedup.txt - - # Create release with properly quoted file arguments - gh release create Nightly \ - --title "Nightly" \ - --notes "Automated nightly build from commit ${{ github.sha }}" \ - --prerelease \ - --target ${{ github.sha }} \ - "${FILES[@]}" + # Only if the deduplicated file list is not empty + if [ -s release_files_dedup.txt ]; then + declare -a FILES + while IFS= read -r -d $'\0' file; do + FILES+=("$file") + done < release_files_dedup.txt + + # Create release with properly quoted file arguments + gh release create Nightly \ + --title "Nightly" \ + --notes "Automated nightly build from commit ${{ github.sha }}" \ + --prerelease \ + --target ${{ github.sha }} \ + "${FILES[@]}" + else + echo "No files to release after deduplication" + exit 1 + fi publish-test-pypi: