Skip to content

[Repo Assist] fix: add retry delay to WorldBank HTTP requests (handles transient 502 errors)#1749

Merged
dsyme merged 2 commits intomainfrom
repo-assist/fix-worldbank-retry-delay-1748-271c6fc951eef501
Apr 17, 2026
Merged

[Repo Assist] fix: add retry delay to WorldBank HTTP requests (handles transient 502 errors)#1749
dsyme merged 2 commits intomainfrom
repo-assist/fix-worldbank-retry-delay-1748-271c6fc951eef501

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Root Cause (Issue #1748)

The CI failure is not related to the FSharp.TypeProviders.SDK update. The actual error (visible in the build log) is:

error FS3021: ... Failed to request 'https://api.worldbank.org/v2/country?per_page=1000&format=json&page=1'. 
Error: System.Net.WebException: The remote server returned an error: (502) Bad Gateway.

The WorldBank type provider makes live HTTP requests at compile time to populate the Countries, Indicators, Regions, and Topics provided types. When the WorldBank API was temporarily returning 502, the type provider threw an exception that became a compiler error (FS3021), causing the test project to fail to build.

The Fix

Previously, retries on failure happened immediately with no delay between attempts. This means all 5 retries would fail in rapid succession during a transient server-side outage (e.g. 502 Bad Gateway), exhausting all retries within milliseconds.

This PR adds a 2-second delay (retryDelayMs = 2000) between retries, so the total retry window is ~10 seconds. This gives the WorldBank API time to recover from brief load spikes or gateway errors before all retries are exhausted.

Changes

  • src/FSharp.Data.WorldBank.Core/WorldBankRuntime.fs: Add Async.Sleep retryDelayMs before each retry in worldBankRequest

Trade-offs

  • Slower failure: If the API is truly unavailable (not just transiently), it takes 10+ extra seconds to exhaust retries. This is acceptable for a type provider that runs at design time.
  • Slower Intellisense on flaky connections: In a development environment with intermittent network issues, the 2s delay would slightly slow down type checking. This is a minor inconvenience.

Note: A more comprehensive fix would pre-seed the WorldBank schema cache with static fixture data, so the type provider never needs to make network requests in CI. That would be a larger change and could be done as a follow-up.

Test Status

  • FSharp.Data.WorldBank.Core builds successfully
  • ⚠️ The FSharp.Data.Tests project (which contains the WorldBank integration tests) requires live WorldBank API access — it cannot be validated in this environment without network access to api.worldbank.org

Closes #1748

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

…02 errors

The WorldBank type provider makes live HTTP requests at compile time to
populate the country/indicator/region/topic types. Previously, retries
happened immediately with no delay, meaning all 5 retries would fail in
rapid succession during transient server-side outages (e.g. 502 Bad Gateway).

Add a 2-second delay between retries so that brief API outages are more
likely to be survived before all retries are exhausted.

Fixes #1748

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review April 17, 2026 11:18
@dsyme dsyme merged commit 4abfd83 into main Apr 17, 2026
3 checks passed
@dsyme dsyme deleted the repo-assist/fix-worldbank-retry-delay-1748-271c6fc951eef501 branch April 17, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI is failing on main

1 participant