Skip to content

feat(sync): create a missing config and variation from link --upsert - #1028

Merged
ctawiah merged 2 commits into
mainfrom
ctawiah/sync-link-upsert
Nov 16, 2026
Merged

ctawiah merged 2 commits into
mainfrom
ctawiah/sync-link-upsert

Conversation

@ctawiah

@ctawiah ctawiah commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Context

A link of a repository source is reviewed and written in one command, and then the resource syncs. When the variation does not exist in LaunchDarkly, the plan stopped with an error that asked the user to create it in the UI first, because a descriptor has no upsert. When the config did not exist, the read of the config failed and stopped the whole plan, including every other variation of the project. Both cases are the first step of an adoption flow: the prompt lives in code and LaunchDarkly has nothing yet.

What changes

  • link --upsert creates the resource in LaunchDarkly when it does not exist. For a variation it also creates the config when LaunchDarkly has none. The plan shows the row as create_server with the reason new, creates config "x", and the same --yes and --no-input flags apply, because the create asks nothing.
  • --model-config-key gives the new variation a model config at its latest version, as add does. --mode sets the mode of a new config. Without it, the source decides: a message list makes a completion config, text makes an agent one. Both flags need --upsert and apply to a variation only.
  • The intent of the link is not stored in the descriptor. It rides on the link run, and applies to the compiled resource of the link both before and after the descriptor is written, so the second read of the state plans the same create.
  • A missing config of an untracked variation is now a row of the plan, not a failure of the whole plan. The row names the config and the flag that creates it, and the other variations of the project are planned as before. A tracked variation whose config answers 404 still stops the sync with an error, as on main, because the config was there at the last sync and a wrong --project gives the same answer.
  • A create of a linked resource needs no sync setting, because LaunchDarkly has nothing yet for a setting to govern. A server_canonical setting still refuses a create.
  • A tool or skill link with --upsert creates the tool or skill through the same publish as a managed file with upsert.
  • CreateConfig on the API client posts the key, the name, and the mode.

Design notes

  • The create reuses the existing mechanics: Upsert on the compiled resource, chooseAction, the create path of applyServerChange, and the publish of the attachment resolver. The only new write is the config create, which runs right before the variation create and tolerates a 409 from a config that another working copy created after the plan.
  • The config is created with no variation, and the variation create follows in the same apply. If the variation create fails, the empty config stays, and the next link --upsert finds it and creates the variation only.
  • A managed variation file keeps its own upsert: true, and a missing config now works for it the same way.

Review focus

  • Is the mode rule right: --mode, else the mode the source implies, else agent?
  • Is an empty config after a failed variation create acceptable, or does the create need a rollback?

Verification

  • go test ./...
  • golangci-lint run ./...
  • TestPromptSyncWithYesDoesNotDeleteTrackedVariationWhenConfigIs404, TestLinkUpsertCreatesTheConfigAndTheVariation, TestLinkUpsertCreatesTheVariationWithAModelConfig, TestLinkUpsertModeOverridesTheSourceMode, TestLinkWithoutUpsertNamesTheMissingConfig, TestLinkUpsertCreatesAMissingTool, TestCreateOfALinkedResourceNeedsNoSetting, TestClientCreatesConfig, and TestSourceLinkFlagsCarryTheUpsertIntent.

🤖 Generated with Claude Code


Note

Overview
sync … link can bootstrap missing LaunchDarkly resources with --upsert: variations get a new config (when absent) plus the variation; tools/skills are created on the same publish path as managed upsert files. Variation-only flags --model-config-key (latest version) and --mode (agent/completion) require --upsert; default mode comes from the source when omitted.

The link run carries upsert intent (linkIntent) through planning and apply without storing it in the descriptor, so the pre- and post-descriptor reads still plan the same create.

Planning no longer aborts the whole project when an untracked variation’s config is missing—it's a create_server row (reason: new, creates config "…") with errors that mention --upsert. Tracked variations still hard-fail on config 404 so local files aren’t deleted on a wrong --project. Linked creates skip sync-setting checks when nothing exists server-side yet.

API: new CreateConfig POST; execute calls it before variation create (409 tolerated). User-facing missing-resource messages now suggest link --upsert instead of UI-only fixes.

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

A link of a source whose variation does not exist in LaunchDarkly stopped with an error, and a missing config stopped the whole plan. A link with --upsert now creates the resource in LaunchDarkly, and the config of a variation when LaunchDarkly has none. The config takes the mode of the source, or --mode, and the name of its key. --model-config-key gives the new variation a model config at its latest version. A missing config is now a row of the plan, so one such variation does not stop the others, and the message names the flag.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ctawiah
ctawiah marked this pull request as ready for review November 16, 2026 20:50
@ctawiah
ctawiah requested a review from a team as a code owner November 16, 2026 20:50
@ctawiah
ctawiah requested review from btesfamariam and nkester-ld and removed request for a team November 16, 2026 20:50

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 348a314. Configure here.

Comment thread internal/sync/prompt/state.go Resolved
Comment thread internal/sync/prompt/state.go Resolved
…wers 404

A 404 of the config became a missing config for every row, so a tracked
variation looked archived in LaunchDarkly, and `sync prompts --yes`
deleted its local file and lock entry. A wrong --project gave the same
result. The 404 is an error again for a tracked variation, and a missing
config only for an untracked one, which a create can make.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ctawiah
ctawiah merged commit e53bd3e into main Nov 16, 2026
11 checks passed
@ctawiah
ctawiah deleted the ctawiah/sync-link-upsert branch November 16, 2026 23: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.

2 participants