Repository navigation
feat(sync): send the repository source in an LD-Sync-Source header (AIC-3974) - #1043
Merged
Merged
Conversation
…IC-3974) LaunchDarkly needs to tell a sync write from a UI or API write, and to know which repository sends it. The User-Agent names ldcli but not the repository, and any script can copy it. Every request from the sync commands now carries LD-Sync-Source with the manifest source of the repository, for example git:acme/support-agent. The runner keeps the source that it resolves from the Git origin and gives it to every API client. The User-Agent does not change, and other ldcli commands send no header. The HTTP client gets MakeRequestWithHeaders, which adds extra headers after the headers that every request sends. The sync client uses it when the transport supports it, and falls back to MakeRequest otherwise, so the test fakes that only implement MakeRequest keep working. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ctawiah
marked this pull request as ready for review
November 18, 2026 19:02
ctawiah
requested review from
apucacao and
nkester-ld
and removed request for
a team
November 18, 2026 19:02
nkester-ld
approved these changes
Nov 18, 2026
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
Every request that
ldcli syncmakes now carries anLD-Sync-Sourceheader with the manifest source of the repository, for examplegit:acme/support-agent. The User-Agent does not change. This is the ldcli half of the ownership lock in launchdarkly/gonfalon#79442 and its stack.Why
LaunchDarkly must tell a sync write from a UI or plain API write, and it must know which repository sends the write. Today ldcli identifies itself only with the
launchdarkly-cli/<version>User-Agent. Any script can copy that header, and it does not name the repository. Since launchdarkly/gonfalon#79268 the sync settings return the sources that sync a resource insyncedSources, so the server can accept a write to a code owned resource when the header value is one of those sources, and reject the rest.What changes
internal/resources:ResourcesClientgetsMakeRequestWithHeaders, and aHeaderClientinterface names it. The extra headers are added after the headers that every request sends, so a caller cannot replace the User-Agent or the API version.MakeRequestcalls it with no extra headers.internal/sync/api: the client getsWithSource. With a source, every read and write sendsLD-Sync-Sourcewhen the transport is aHeaderClient. Without a source, or with a transport that only hasMakeRequest, the request goes out as before.internal/sync/prompt: the runner keeps the source that it resolves from the Git origin and gives it to every API client it builds.Other ldcli commands do not send the header.
Testing
go test ./...passes, andgolangci-lint runreports 0 issues on the changed packages.TestMakeRequestWithHeaders: the header goes out and the User-Agent, API version, and token stay.TestClientWithSourceSendsTheSyncSourceHeader,TestClientWithoutSourceSendsNoSyncSourceHeader,TestClientWithSourceFallsBackToAPlainTransport.TestSyncSendsTheRepositorySourceWithEveryRequest: a push sendsgit:example/repowith every request.A manual run against staging waits for the gonfalon lock to check the header.
Requirements
Related issues
🤖 Generated with Claude Code
Note
Overview
ldcli syncnow tags every API call withLD-Sync-Source(e.g.git:acme/support-agent) so LaunchDarkly can distinguish repo sync writes from UI or generic API writes and enforce ownership againstsyncedSources.The HTTP stack gains
HeaderClient/MakeRequestWithHeadersonResourcesClient, with extra headers applied after the standardUser-AgentandLD-API-Versionso callers cannot override them. The sync API client addsWithSourceand routes reads/writes through a sharedsendpath that setsLD-Sync-Sourcewhen a source is configured and the transport supports headers; otherwise behavior is unchanged. The prompt sync runner resolves the Git manifest source at startup and attaches it to every API client it builds—other CLI commands are unaffected.Coverage includes unit tests for header merging, source on/off, plain-transport fallback, and end-to-end sync runs asserting the header on every request.
Reviewed by Cursor Bugbot for commit 0c5ad6a. Bugbot is set up for automated code reviews on this repo. Configure here.
Related Jira issue: AIC-3974: [ldcli] Send the sync source in an LD-Sync-Source header on every sync request