fix(ios): do not fail a completed TestFlight upload on empty notes arguments
The scheduled TestFlight uploads have been failing after the upload already succeeded.
ios/scripts/upload-testflight.sh finishes the App Store Connect upload, then dies setting the "What to Test" notes:
./ios/scripts/upload-testflight.sh: line 1741: NOTES_SOURCE_ARGS[@]: unbound variable
The script runs under set -euo pipefail, and the macOS runner's /bin/bash is 3.2.57. Before bash 4.4, expanding an empty array as "${arr[@]}" while set -u is active is an unbound-variable error rather than an empty list. NOTES_SOURCE_ARGS is populated only in range-notes mode, or when the changelog version guard is on and the archived marketing version parses. The appstore lane takes neither branch, so the array is empty.
What this was actually costing
The binary was already on App Store Connect every time. From the evidence artifact of run 35733739022:
upload.log:{"uploadId":"41b619d5-...","fileName":"cmux-resigned.ipa","fileSize":53037920,"uploaded":true}export.log:** EXPORT SUCCEEDED **- the step log:
Upload committed in App Store Connect.
Because the job was then marked failed, Make build available to official internal testers and Assign build to internal TestFlight group were skipped. So the build reached App Store Connect and reached nobody. That is the part worth fixing quickly: this reads as a broken build pipeline, but it is a delivery failure — the uploads worked and the testers never got them.
ios-appstore-upload failures in the last 100 runs | 61 |
ios-testflight failures in the last 100 runs | 73 |
| combined runner time per the workflow inventory | ~250 hours/week |
The failures are interleaved with successes, which matches the cause exactly: a run succeeds when the notes arguments happen to be non-empty.
This also explains why nobody has diagnosed it from the Actions UI. The archive step's log is truncated by GitHub roughly two minutes before the failure, so the error line is not in the web log at all — it only survives in cmux-app-upload.log inside the evidence artifact.
Resulting behavior
Every possibly-empty array in the script now uses ${arr[@]+"${arr[@]}"}, the form already used twice in this same script (lines 939 and 963) and in five other places in the repository. It is identical for a populated array and expands to nothing for an empty one.
NOTES_SOURCE_ARGS— the live bug.XCODE_AUTH_ARGS— the same defect at two sites, reachable whenever the App Store Connect key variables are unset, which is any local run.EXTERNAL_GROUP_SELECTOR— always has a value from itselse, so not a live bug; guarded for uniformity so the test can state a single rule.
Validation
Two commits, per the repository's regression policy, so CI records that the test detects the bug:
6fcaf99addstests/test_ios_upload_array_expansion.pyonly. It exits 1 against the current script, namingNOTES_SOURCE_ARGSand bothXCODE_AUTH_ARGSsites.fb1516dapplies the fix. The test exits 0.
The test pins the rule statically and also checks the guard's behaviour directly: it expands to zero arguments for an empty array and preserves argument boundaries for a populated one.
bash -n parses clean. shellcheck --severity=error reports only the pre-existing SC1087 at line 454, a $key[ inside a sed regex that this change does not touch.
Not verified by me: an actual upload run. That needs the scheduled workflow or a dispatch with the App Store Connect credentials, so the first real proof will be the next scheduled ios-appstore-upload after this merges.
Not fixed here
The same pattern exists at 40 other sites across ios/scripts/ and scripts/ — ios/scripts/reload.sh has seven, scripts/lint-ios-package-conventions.sh has nine. Most are probably unreachable in the same way EXTERNAL_GROUP_SELECTOR is, and proving reachability one by one is a separate change. This pull request fixes the script with a demonstrated production failure and leaves the sweep for someone who wants to take it on.
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Fixes the TestFlight upload script so a completed App Store Connect upload no longer fails the job when the "What to Test" notes arguments are empty.
- The script died on an unbound-variable error expanding an empty array under the runner's bash 3.2, marking the job failed and skipping the steps that assign the build to internal testers; 61 of the last 100 appstore-upload runs and 73 of the last 100 testflight runs failed this way.
- Every possibly-empty array now uses the guarded
${arr[@]+"${arr[@]}"}form:NOTES_SOURCE_ARGS,XCODE_AUTH_ARGS(two sites), andEXTERNAL_GROUP_SELECTOR. - Adds a regression test that fails against the old script and passes with the fix.