Skip to content

Fix notarization failing at random when the Apple service is slow - #772

Merged
goneng merged 1 commit into
masterfrom
notarize-by-submission-id
Oct 25, 2026
Merged

goneng merged 1 commit into
masterfrom
notarize-by-submission-id

Conversation

@goneng

@goneng goneng commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Take the submission id from the JSON output of notarytool submit and wait for it by id, so a dropped --wait no longer makes the step look up the id in a half-written log.

The old step ran notarytool submit --wait | tee, then read the id with tail -3 | cut -d':' -f2. When --wait returned while the status was still "In Progress", the last lines were the upload header, so the id came out as the zip path and notarytool log failed with "must be a valid UUID" (exit 64). The pipe also hid the exit status of notarytool, because the shell has no pipefail. This broke PR builds at random, for example run 40074816682 (x86_64) and run 40085489006 (arm64).

  • Submit with --output-format json and read the id from it
  • Wait by id, polling the status again if the wait ends early (up to 6 times)
  • Fail the step unless the final status is Accepted
  • Quote the credentials and stop on the first error (set -euo pipefail)
  • Worst case the wait loop can run about 2h10m (6 attempts of up to 20m plus a 20s sleep); this is intentional, to ride out a slow Apple service

Test plan:

  • Workflow YAML parses and the step passes bash -n
  • notarytool 1.1.0 has wait, --timeout and --output-format json
  • The notarization steps only run with the signing secrets, so this PR's own CI run is the real check; run it more than once

@goneng
goneng marked this pull request as ready for review October 24, 2026 14:24
@goneng
goneng requested a review from hannesa2 October 24, 2026 14:24
@goneng goneng added bugfix pipeline CI pipeline labels Oct 24, 2026

@hannesa2 hannesa2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor non-blocking observations:

  1. Timeout budget: 6 attempts × (--timeout 20m + sleep 20s) ≈ up to 2h 10m. No timeout-minutes is set for the job (default is 360 min), so this isn't critical—though it might be worth mentioning in the PR description, if this duration is intentional.
  2. The || echo "notarytool wait returned early (attempt $attempt)" construct swallows any error returned by wait (e.g., network or authentication issues), not just the expected timeout. While this doesn't cause functional problems—since the subsequent notarytool info call will re-query the actual status—it does mean that a genuine authentication error would repeat 6 times before the loop terminates, rather than failing immediately.
  3. Regarding case "$STATUS" in Accepted|Invalid|Rejected): If notarytool info consistently returns unknown (e.g., due to a persistent API error), the loop will run through all 6 attempts before exiting with an error. This is the correct, expected behavior (not a bug).
  4. The plutil -extract ... -o - - command is used in essentially the same way twice (for both id and status); this could be refactored into a small shell function—purely as a stylistic improvement.

Overall, this is a solid and correct fix. I would be happy to merge it as is; you might just want to briefly mention point 1 in the PR description.

Take the submission id from the JSON output of `notarytool submit` and wait for it by id, so a dropped `--wait` no longer makes the step look up the id in a half-written log.

- Submit with --output-format json and read the id from it
- Wait by id, polling the status again if the wait ends early
- Fail the step unless the final status is Accepted
- Quote the credentials and stop on the first error
@goneng
goneng force-pushed the notarize-by-submission-id branch from db9935a to 8129498 Compare October 25, 2026 05:13
@goneng
goneng merged commit 4760214 into master Oct 25, 2026
2 checks passed
@goneng
goneng deleted the notarize-by-submission-id branch October 25, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants