Skip to content

fix: migrate flag listing to REST API 20240415 with pagination - #251

Merged
cspath1 merged 2 commits into
launchdarkly:mainfrom
austinbutler:fix/rest-api-20240415
Sep 15, 2026
Merged

cspath1 merged 2 commits into
launchdarkly:mainfrom
austinbutler:fix/rest-api-20240415

Conversation

@austinbutler

@austinbutler austinbutler commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Context

The action's flag-list request still uses REST API version 20220603. LaunchDarkly's migration guide requires upgrading to 20240415 before the December 31, 2026 retirement deadline.

This updates the request to 20240415 and adds pagination for active and archived flags. The new API paginates flag listings, so changing the header alone would leave flag detection limited to the first page.

Testing

HTTP fixture tests cover multiple pages of active and archived flags, short and empty pages, request headers and query parameters, preserved flag metadata, and errors on first and later pages without returning a partial flag inventory.

Passed locally with Go 1.25.14:

  • go test ./...
  • go test -race ./internal/ldclient
  • Vendored action build, go vet -mod=vendor ./..., and the existing golangci-lint pre-commit hook

Secret-dependent end-to-end tests were not run locally and need maintainer involvement.


Note

Overview
Migrates LaunchDarkly flag listing from REST API 20220603 to 20240415 and implements offset/limit pagination (100 per page) until an empty page, for both active flags and optional archived (state:archived) collections.

getFlags now copies query params, drives the page loop, and delegates each request to new getFlagPage; CHANGELOG documents the fix. Adds flags_test.go with HTTP fixtures for multi-page active/archived flows, metadata preservation, query param handling, and error paths on first or later pages.

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

@austinbutler
austinbutler marked this pull request as ready for review September 9, 2026 23:31
@austinbutler
austinbutler requested a review from a team as a code owner September 9, 2026 23:31
Comment thread internal/ldclient/flags.go Outdated
if err != nil {
return []ldapi.FeatureFlag{}, err
}
// A short page does not guarantee that there are no more flags.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this comment is true, why are are still returning flags?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is based on your migration guide:

To page through the results, repeat each request, increasing the offset by the limit each time, until one of the following is true:

the items array in the response is empty

And basically this is just my best guess from interpreting that. However, this depends on how your API actually behaves, and you all would know better than I would.

Also, re-reading that page again, it looks like we should be increasing offset by limit?

Ultimately this PR was intended to get the ball rolling. Let me know your thoughts, and please feel free to update this branch and/or request changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the change to offset by limit in CI with some extra logging, the flags fetched and values matched between the old version and this PR's changes. Also update the wording on this comment.

@cspath1
cspath1 merged commit d8b3a47 into launchdarkly:main Sep 15, 2026
8 checks passed
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.

3 participants