Skip to content

chore(deps): update LDCLI to api-client-go v24 for API version 20240415 [REL-16083] - #832

Open
cjhensen wants to merge 2 commits into
mainfrom
cursor/api-client-go-v4-header-202c
Open

cjhensen wants to merge 2 commits into
mainfrom
cursor/api-client-go-v4-header-202c

Conversation

@cjhensen

@cjhensen cjhensen commented Sep 29, 2026 •

Copy link
Copy Markdown

HUMAN

I've been migrating gonfalon API consumers to the latest API version. This is a PR for the cli to move it to API V4.

ldcli now sends LD-API-Version: 20240415 on every non-beta request, so commands behave the same no matter which API version the access token defaults to. Tokens from ldcli login already use this version, but tokens passed with --access-token or saved in config can default to older versions that are being retired. The typed API client moves from api-client-go v14 to v24, which adds the header by default, and the HTTP client behind the generated resource commands now sets it as well. Beta commands still send beta.

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

REL-16083 (Update LDCLI)

Describe the solution you've provided

  • Bumps github.com/launchdarkly/api-client-go from v14.0.0 to v24.0.0, the latest major. v21.0.0 is the first major whose prepareRequest adds LD-API-Version: 20240415 when the request has no version. The only breaking change ldcli hit is NewPatchOperation dropping its value argument; internal/flags/client.go builds the struct directly, and the JSON sent is unchanged.
  • internal/resources/client.go: MakeRequest sets LD-API-Version: 20240415 unless the operation is beta. The generated resource commands and the hand-written commands (flags toggle-on/off, flags archive, whoami, members invite, sdk-active, sourcemaps and symbols upload, setup verify) all go through this client, not api-client-go.
  • Tests pin the header for both clients: 20240415 for the typed client and for non-beta MakeRequest, beta for beta MakeRequest.
  • v24 models reject responses missing a spec-required field. The Terraform provider runs v24.0.0 for the same flag, project, environment, and member calls ldcli makes. The two list calls it doesn't make (GetFeatureFlags in dev-server, GetProjects in setup) return reps that always serialize the required fields.

v4 needed no pagination or response-shape code changes:

  • dev-server pages the flag list at limit=100 until a short page and reads only items and variations (internal/dev_server/adapters/api.go).
  • The setup wizard pages projects and environments at limit=100 (internal/setup/service.go).
  • Quickstart reads environments from the single-flag GET, which v4 doesn't change (internal/quickstart/messages.go).
  • Symbols and sourcemaps upload read only the project _id.
  • compare isn't exposed: the spec marks it deprecated and the generator skips deprecated params.

User-visible changes for anyone on an older token (--access-token or config):

  • flags list, segments list, custom-roles list, and workflows list return 20 items by default, and access-tokens list returns 25. Plaintext output already prints Showing results 1 - 20 of N. Use --offset 20 for additional results., and JSON output carries totalCount and _links.next. Tokens older than 20220603 also get the project list paged at 20, and projects omit environments unless --expand environments is passed.
  • flags list omits each flag's environments unless the request uses --filter filterEnv:<env>.
  • Filters v4 removed now return a 400: followerId, hasDataExport, status, contextKindTargeted, and segmentTargeted on the flag list, accessCheck on the member list, and --expand projects or --expand roles on the team list.

Describe alternatives you've considered

  • Stopping at v21, the minimum major with the default header. v24 is the latest and matches the Terraform provider.
  • Relying on api-client-go alone. That covers only setup, quickstart, and dev-server; the generated commands use their own HTTP client.

Additional context

  • Not changed here: the five ai-configs agent-graph commands require LD-API-Version: beta per the spec, but their tag has no "(beta)" and the generated --ld-api-version flag is never sent as a header. They sent no version before this change and send 20240415 after it; both fail. This needs its own fix in the generator.
  • go test ./... and golangci-lint v1.63.4 pass. No release is included.

Note

Overview
Upgrades ldcli to LaunchDarkly REST API version 20240415 by bumping api-client-go from v14 to v24 and aligning both HTTP paths with that version.

The typed client (setup, dev-server, flags, projects, members, etc.) now comes from v24, which sends LD-API-Version: 20240415 on requests. The separate internal/resources client used by generated and hand-written commands now sets the same header on non-beta calls; beta operations still send beta. Flag patch updates build PatchOperation structs directly after v24 dropped NewPatchOperation's value helper—the JSON payload is unchanged.

Tests assert LD-API-Version for the typed client and for MakeRequest (non-beta vs beta). Dependency lockfiles reflect the major client bump (including dropping golang.org/x/oauth2 as an indirect dep).

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

@cjhensen
cjhensen requested a review from a team September 29, 2026 14:10
v21 and later send `LD-API-Version: 20240415` on every request that doesn't
set its own version, so the typed-client calls (setup, quickstart, dev-server)
now get API v4 responses regardless of the caller's token default.

v24 dropped the value argument from `NewPatchOperation`; build the struct
directly instead. The serialized patch is unchanged.
The generated resource commands and the hand-written commands use their own
HTTP client instead of api-client-go and sent no version header, so their
responses followed whatever default version the access token carried. Send
the current version explicitly; beta operations keep sending `beta`.
@cjhensen
cjhensen force-pushed the cursor/api-client-go-v4-header-202c branch from a8adcff to 5af62e9 Compare September 29, 2026 14:14
@cjhensen
cjhensen marked this pull request as ready for review September 29, 2026 15:35
@cjhensen
cjhensen requested a review from a team as a code owner September 29, 2026 15:35
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.

1 participant