1212from sp_cli .constants import (ARTIFACT_TYPES , CANCEL_REASON_MIN_LENGTH ,
1313 COMMIT_SHA_LENGTH , ERROR_GROUP_BY ,
1414 ERROR_SEVERITIES , ERROR_TYPES , EXIT_TIMEOUT ,
15- INFRA_ERROR_TYPES , LOG_CONTAINS_MAX_LENGTH ,
16- LOG_LEVELS , LOG_SOURCES , MAX_OFFSET ,
17- MAX_PAGE_LIMIT , MAX_REGRESSION_TEST_IDS ,
18- PLATFORMS , PR_SCAN_DEFAULT , PR_SCAN_MAX ,
15+ EXIT_WAIT_ABORTED , INFRA_ERROR_TYPES ,
16+ LOG_CONTAINS_MAX_LENGTH , LOG_LEVELS , LOG_SOURCES ,
17+ MAX_OFFSET , MAX_PAGE_LIMIT ,
18+ MAX_REGRESSION_TEST_IDS , PLATFORMS ,
19+ PR_SCAN_DEFAULT , PR_SCAN_MAX ,
1920 RUN_PENDING_STATUSES , RUN_STATUSES ,
2021 RUN_UNSUCCESSFUL_STATUSES , SAMPLE_STATUSES ,
2122 WAIT_INTERVAL_DEFAULT , WAIT_INTERVAL_MAX ,
@@ -778,7 +779,9 @@ def run_wait(ctx: click.Context, run_ids: Tuple[int, ...], interval: int,
778779
779780 Exits 0 only if every run finished successfully; a failed or canceled run
780781 exits 1 and a timeout exits 9, which lets a script gate on the result
781- without parsing the output.
782+ without parsing the output. If the wait itself cannot be completed the exit
783+ code describes that instead: 3 through 8 for an API error that maps to one,
784+ 10 for anything else. Nothing but a run's own verdict exits 1.
782785
783786 A run whose status is `pass` exits 0 even if it recorded results for only a
784787 fraction of its samples, because the API derives that status from the rows
@@ -797,7 +800,12 @@ def run_wait(ctx: click.Context, run_ids: Tuple[int, ...], interval: int,
797800 record = client .get (f'/runs/{ run_id } ' )
798801 except ApiError as error :
799802 render_error (error , output )
800- raise SystemExit (error .exit_code )
803+ # An error with no code of its own exits 1 everywhere else, but
804+ # this command has already given 1 a meaning: a run you waited
805+ # for failed. Collapsing both into 1 tells a merge gate to block
806+ # the branch when the platform merely returned a 500.
807+ code = error .exit_code
808+ raise SystemExit (EXIT_WAIT_ABORTED if code == 1 else code )
801809 status = record .get ('status' )
802810 if status not in RUN_PENDING_STATUSES :
803811 finished [run_id ] = record
0 commit comments