Conversation
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
force-pushed
the
cursor/api-client-go-v4-header-202c
branch
from
September 29, 2026 14:14
a8adcff to
5af62e9
Compare
cjhensen
marked this pull request as ready for review
September 29, 2026 15:35
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: 20240415on every non-beta request, so commands behave the same no matter which API version the access token defaults to. Tokens fromldcli loginalready use this version, but tokens passed with--access-tokenor 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 sendbeta.Requirements
Related issues
REL-16083 (Update LDCLI)
Describe the solution you've provided
github.com/launchdarkly/api-client-gofrom v14.0.0 to v24.0.0, the latest major. v21.0.0 is the first major whoseprepareRequestaddsLD-API-Version: 20240415when the request has no version. The only breaking change ldcli hit isNewPatchOperationdropping its value argument;internal/flags/client.gobuilds the struct directly, and the JSON sent is unchanged.internal/resources/client.go:MakeRequestsetsLD-API-Version: 20240415unless 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.20240415for the typed client and for non-betaMakeRequest,betafor betaMakeRequest.GetFeatureFlagsin dev-server,GetProjectsin setup) return reps that always serialize the required fields.v4 needed no pagination or response-shape code changes:
limit=100until a short page and reads onlyitemsandvariations(internal/dev_server/adapters/api.go).limit=100(internal/setup/service.go).environmentsfrom the single-flag GET, which v4 doesn't change (internal/quickstart/messages.go)._id.compareisn't exposed: the spec marks it deprecated and the generator skips deprecated params.User-visible changes for anyone on an older token (
--access-tokenor config):flags list,segments list,custom-roles list, andworkflows listreturn 20 items by default, andaccess-tokens listreturns 25. Plaintext output already printsShowing results 1 - 20 of N. Use --offset 20 for additional results., and JSON output carriestotalCountand_links.next. Tokens older than20220603also get the project list paged at 20, and projects omitenvironmentsunless--expand environmentsis passed.flags listomits each flag'senvironmentsunless the request uses--filter filterEnv:<env>.followerId,hasDataExport,status,contextKindTargeted, andsegmentTargetedon the flag list,accessCheckon the member list, and--expand projectsor--expand roleson the team list.Describe alternatives you've considered
Additional context
ai-configsagent-graph commands requireLD-API-Version: betaper the spec, but their tag has no "(beta)" and the generated--ld-api-versionflag is never sent as a header. They sent no version before this change and send20240415after 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-gofrom 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: 20240415on requests. The separateinternal/resourcesclient used by generated and hand-written commands now sets the same header on non-beta calls; beta operations still sendbeta. Flag patch updates buildPatchOperationstructs directly after v24 droppedNewPatchOperation's value helper—the JSON payload is unchanged.Tests assert
LD-API-Versionfor the typed client and forMakeRequest(non-beta vs beta). Dependency lockfiles reflect the major client bump (including droppinggolang.org/x/oauth2as an indirect dep).Reviewed by Cursor Bugbot for commit 5af62e9. Bugbot is set up for automated code reviews on this repo. Configure here.