What causes 502s when Xcode Cloud clones from GitHub?

I have an inconsistent Xcode Cloud failure that I'm hoping to learn more about?

Additional context is available in Apple Support case 102378073626 and Feedback Assistant FB13769150.

Every 3 months, ~half of my project's Xcode Cloud builds will fail for a few days in a row. I usually file a support request with Apple, they fix something on their end, builds succeed, and then exhibit the same failures again in 3 months.

I'm hoping to learn anything that y'all can share about:

  1. Why does this happen?
  2. Does it coincide with new macOS versions being deployed onto Xcode Cloud?
  3. What did Apple do to fix it each time?
  4. Is there anything I can change about my project to make the failure less likely? (Such as putting a delay between the clone, brew install, and pod install steps that all hammer GitHub?)

Specific symptoms: Xcode Cloud builds will fail after receiving an HTTP 502 from GitHub. This usually happens when it attempts to clone a repo, brew install, or pod install.

One example:

[!] Error installing FirebaseSessions [!] /usr/bin/git clone https://github.com/firebase/firebase-ios-sdk.git /Volumes/workspace/tmp/d20240809-12044-znknw7 --template= --single-branch --depth 1 --branch CocoaPods-10.28.0 Cloning into '/Volumes/workspace/tmp/d20240809-12044-znknw7'... error: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502 fatal: expected flush after ref listing Error Command exited with non-zero exit-code: 1

Update: The issue was temporarily resolved by an Apple-side modification, then began to recur on November 1, three months after the previous occurrence.

What causes 502s when Xcode Cloud clones from GitHub?
 
 
Q