Hive Hive
Sign in

fix(cli): retry run metadata upload on transient errors

GitHub issue · Closed

Metadata
Source
tuist/tuist #10842
Updated
Jun 24, 2026
Domains
CLI
Details

Describe here the purpose of your PR.

The CLI’s createCommandEvent call (the one that logs Uploading run metadata... from TrackableCommand) is the only step in the analytics upload flow without a retry wrapper. A single transient 5xx from the server fails the CI command and surfaces as Failed to upload run metadata: unknownError(502), forcing the user to re-run their CI job. Artifact uploads (MultipartUploadArtifactService) already wrap their work in RetryProvider.

This PR injects RetryProviding into CreateCommandEventService and runs the API call inside runWithRetries, so transient failures (502/503/504, network errors) are retried up to three times with backoff before bubbling up. Same pattern as the existing artifact-upload path.

How to test locally

Document how to test your changes locally

  • Point the CLI at a server that returns a 502 once and then 200 (e.g. a stub or a temporarily-down endpoint). Run any tracked command and confirm Uploading run metadata... succeeds without surfacing unknownError(502).
  • Inject a mock RetryProviding in a unit test to assert that createCommandEvent calls the underlying API up to 3 times on failure.
  • Sanity check: a 4xx (e.g. unauthorized) still surfaces as before — the retry will exhaust quickly given the tiny backoff and throw the same typed error.
Comments
T
tuist[bot] May 18, 2026

🛠️ Tuist Run Report 🛠️

Tests 🧪
Scheme Status Cache hit rate Tests Skipped Ran Commit
TuistAcceptanceTests 0 % 0 0 0 6d905ec31
TuistUnitTests 43 % 2845 5 2840 6d905ec31
Flaky Tests ⚠️
  • TuistUnitTests: 1 flaky test (View all)
Test case Module Suite
parseTestStatuses_returnsCorrectStatuses() TuistXCResultServiceTests XCResultServiceTests
Builds 🔨
Scheme Status Duration Commit
TuistAcceptanceTests 1m 53s 6d905ec31
TuistUnitTests 2m 9s 6d905ec31