Skip to content

Retry rate-limited flag requests - #253

Merged
cspath1 merged 1 commit into
launchdarkly:mainfrom
MercuryTechnologies:fix/ld-429-retries
Sep 30, 2026
Merged

cspath1 merged 1 commit into
launchdarkly:mainfrom
MercuryTechnologies:fix/ld-429-retries

Conversation

@austinbutler

@austinbutler austinbutler commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Following my PR #251, I noticed a higher rate of 429s from LaunchDarkly's API in our CI. Makes sense, pagination means more requests.

So this PR adds retries. It's based on your own documentation for rate limiting.

I've run it in our CI for a few weeks, resulting in thousands of runs, and it handles 429s properly and the overall failure rate remains comparable to before the migration to pagination.

Please feel free to do what you want with this PR, for example if lots of changes are needed and you want to do it yourself, take whatever you want from this PR. I only want to raise the issue and ensure it gets addressed somehow.


Note

Overview
Replaces the paginated LaunchDarkly flag list client with a context-aware flagFetcher built on go-retryablehttp. GetAllFlags now accepts context.Context (wired from main), applies a 120s inventory timeout, and only retries HTTP 429 responses—using Retry-After, reset headers, and remaining-quota headers per LD’s rate-limiting docs, with exponential backoff when hints are missing.

Between pages it can pause proactively when responses show exhausted quota (including before switching active → archived). Failures return structured flagFetchError reasons (canceled, rate-limit deadline/exhausted, decode, etc.), avoid partial flag lists on mid-inventory errors, and surface cancellation/timeouts while reading response bodies. LD_FLAG_FETCH JSON diagnostics log start/summary, rate limits, and intended waits for CI observability.

Reviewed by Cursor Bugbot for commit 357fdfd. Bugbot is set up for automated code reviews on this repo. Configure here.

@austinbutler
austinbutler marked this pull request as ready for review September 29, 2026 21:21
@austinbutler
austinbutler requested a review from a team as a code owner September 29, 2026 21:21
@cspath1

cspath1 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

@austinbutler thanks for this! I can get this merged and cut a new release for it!

@cspath1
cspath1 merged commit 4e7605d into launchdarkly:main Sep 30, 2026
8 checks passed
cspath1 added a commit that referenced this pull request Sep 30, 2026
Releases two changes that have been sitting on main:

  #253  retry rate-limited flag requests, and preserve cancellation and
        timeout errors while reading flag responses
  #255  pelletier/go-toml/v2 to v2.4.3 (XRAY-1033007)

Patch rather than minor: #253 is retry and error-propagation behaviour,
which the contributor filed under Fixed, and no inputs or outputs
changed.

Two corrections to repository bookkeeping while here:

The version constant was still 2.3.1. v2.3.2 was tagged directly at the
#254 merge commit without a prepare-release commit, so the constant and
the metadata pins never moved. Both are now at 2.3.3.

The changelog had no 2.3.2 entry for the same reason, even though
v2.3.2 was a real release that Gonfalon pins. Backfilled it from #254.

Also floats the docker/ entry point example on `@v2` to match the two
root Action examples above it, which already used `@v2`. That line no
longer needs rewriting each release, and the "pin to a release that
includes the docker/ entry point" caveat is obsolete now it floats. The
`dockerImage` input keeps an exact tag.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cspath1 cspath1 mentioned this pull request Sep 30, 2026
cspath1 added a commit that referenced this pull request Sep 30, 2026
Releases two changes that have been sitting on main:

  #253  retry rate-limited flag requests, and preserve cancellation and
        timeout errors while reading flag responses
  #255  pelletier/go-toml/v2 to v2.4.3 (XRAY-1033007)

Patch rather than minor: #253 is retry and error-propagation behaviour,
which the contributor filed under Fixed, and no inputs or outputs
changed.

Two corrections to repository bookkeeping while here:

The version constant was still 2.3.1. v2.3.2 was tagged directly at the
#254 merge commit without a prepare-release commit, so the constant and
the metadata pins never moved. Both are now at 2.3.3.

The changelog had no 2.3.2 entry for the same reason, even though v2.3.2
was a real release that Gonfalon pins. Backfilled it from #254.

Also floats the docker/ entry point example on `@v2` to match the two
root Action examples above it, which already used `@v2`. That line no
longer needs rewriting each release, and the "pin to a release that
includes the docker/ entry point" caveat is obsolete now it floats. The
`dockerImage` input keeps an exact tag.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Prepares the **2.3.3** release by aligning repo metadata with changes
already on `main`, without altering action inputs or outputs in this
diff.
> 
> **`CHANGELOG.md`** adds a **2.3.3** *Fixed* section (rate-limit
retries, preserving cancel/timeout errors on flag reads, `go-toml/v2`
bump for XRAY-1033007) and backfills **2.3.2** (Go 1.26.8 toolchain and
dependency/image pins) after v2.3.2 was tagged without a prepare-release
commit.
> 
> **`internal/version/version.go`** updates the version constant from
`2.3.1` to **`2.3.3`**. **`docker/action.yml`** default and example
`dockerImage` tags move from `2.3.1` to **`2.3.3`**.
> 
> **`README.md`** switches the docker entry-point example from a pinned
`@v2.3.1` to **`@v2`** (matching root action examples) while keeping the
mirrored-image example on tag **`2.3.3`**.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4fce911. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants