Skip to content

Commit 5367cc3

Browse files
committed
ci: retry spec fetch with backoff
A transient CDN 520 failed the sdk-typescript scheduled release on 2026-07-07; the same single-shot fetch lives here. Retry up to 5 times with exponential backoff so the daily release run survives upstream blips.
1 parent 7a06f1e commit 5367cc3

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

generate.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,27 @@
1717
GENERATED_DIR = Path("src/roxy_sdk/_generated")
1818

1919

20-
def fetch_spec() -> dict:
20+
def _fetch_with_retry(url: str, attempts: int = 5) -> bytes:
21+
"""Retry with backoff: a transient upstream error (CDN 520) must not fail the release run."""
22+
import time
2123
import urllib.request
2224

25+
for attempt in range(1, attempts + 1):
26+
try:
27+
with urllib.request.urlopen(url) as resp:
28+
return resp.read()
29+
except Exception as err:
30+
if attempt == attempts:
31+
raise
32+
delay = 2**attempt
33+
print(f"Fetch attempt {attempt}/{attempts} failed ({err}), retrying in {delay}s")
34+
time.sleep(delay)
35+
raise RuntimeError("unreachable")
36+
37+
38+
def fetch_spec() -> dict:
2339
print(f"Fetching OpenAPI spec from {SPEC_URL}")
24-
with urllib.request.urlopen(SPEC_URL) as resp:
25-
spec = json.loads(resp.read())
40+
spec = json.loads(_fetch_with_retry(SPEC_URL))
2641

2742
# Patch server URL to absolute prod URL
2843
if spec.get("servers") and spec["servers"][0].get("url") == "/api/v2":

0 commit comments

Comments
 (0)