feat: scaffold Experiments family resources (autogen stage 2)#479
Draft
github-actions[bot] wants to merge 2 commits into
Draft
feat: scaffold Experiments family resources (autogen stage 2)#479github-actions[bot] wants to merge 2 commits into
github-actions[bot] wants to merge 2 commits into
Conversation
…on_settings resources (autogen stage 2) Covers the Experiments API family: - launchdarkly_experiment (resource + data source): createExperiment, getExperiment, patchExperiment, createIteration. Destroy archives the experiment (the API has no delete endpoint). - launchdarkly_experimentation_settings (resource + data source): getExperimentationSettings, putExperimentationSettings as a project singleton. Updates scripts/driftreport/mapping.yaml to mark the family covered. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ngs read ordering Two idempotency fixes found while verifying the Experiments scaffold against a real LaunchDarkly account: - launchdarkly_experiment: iteration.randomization_unit was Optional+Computed with no default, but the iteration object is preserved verbatim from the plan (the API response cannot be converted back into the iteration input), so a Computed value left unset in config remained unknown after apply and tripped Terraform's "provider produced inconsistent result" check. Make it Optional-only; omitting it lets the API apply the project default. - launchdarkly_experimentation_settings: the API returns randomization units in a different order than submitted (the default unit comes back first), so the read produced a list whose order did not match the plan/state. This caused an "inconsistent result after apply" error and a perpetual diff. Reorder the API response to match the order already in the model, appending any extra units. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
Stage-3 verification (run 12)Verified the Experiments-family scaffold against a real LaunchDarkly account. Verdict: pass, with two idempotency fixes pushed.
|
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.
Summary
This PR was scaffolded by the LaunchDarkly autogen pipeline (stage 2) and needs human review per stage 3. Stage-3 verification runs automatically on this PR.
Adds Terraform coverage for the Experiments API family via two resources (each with a data source):
launchdarkly_experiment— environment-scoped experiment. ModelscreateExperiment,getExperiment,patchExperiment, andcreateIteration. The experiment is created together with its first (draft) iteration; changing anyiterationfield issuescreateIterationto produce a new draft iteration.name/descriptionupdate via theupdateName/updateDescriptionsemantic-patch instructions, andarchivedtoggles viaarchiveExperiment/restoreExperiment.launchdarkly_experimentation_settings— project singleton. ModelsgetExperimentationSettings/putExperimentationSettings(the project's allowed randomization units). Create/Update are both PUT; Delete is state-only.scripts/driftreport/mapping.yamlis updated to mark the Experiments familycovered. The list endpointsgetExperimentsandgetExperimentsAnyEnvare intentionally not modeled (the singular get covers declarative reads).This is a stable (non-beta) API surface (
ExperimentsApiService), so no beta client is required.Manual reviewer steps
My
GITHUB_TOKENcannot modify.github/workflows/*, so the acceptance-test matrix was not edited. A maintainer must add these two lines under thetest_case:list in.github/workflows/test.yml:Both prefixes use a trailing underscore so they do not overlap (
TestAccExperiment_does not matchTestAccExperimentationSettings*). The data-source testTestAccDataSourceExperimentationSettings_basicis already covered by the existingTestAccDataSourcematrix entry. (Stage-3 verification re-checks this.)Known limitations / things to verify against a real account
The acceptance tests do not run in this push (the matrix line is a manual step above), so a reviewer should validate end-to-end:
iteration. The API response shape (IterationRep/FlagRep) cannot be converted back into theiterationinput faithfully (e.g.FlagRepexposestargetingRule, not the inputruleId). The resource therefore preserves the configurediterationfrom prior state on read and refreshes only the top-level fields. As a consequence, import does not populateiteration— it must be added to config after import (documented inimport.shand the schema).launchdarkly_experimentarchives it (archiveExperiment).project_key,environment_key,key,maintainer_id,holdout_id, andtagsareRequiresReplace(the patch API cannot change them); a replace will archive the old experiment and create a new one with the same key — verify the API accepts re-using an archived experiment's key, or these should become hard errors instead.patchExperimentis called with aninstructionsbody and the generated client's defaultContent-Type: application/json(same as the existinglaunchdarkly_teamresource). Confirm experiments accept instructions without thedomain-model=launchdarkly.semanticpatchcontent-type suffix.experimentation_settingsrandomization-unit ordering. Read maps the API'srandomizationUnitsin returned order (filtering_hiddensystem units). If the API reorders relative to the submitted list, this could surface a plan inconsistency — verify order is preserved, otherwise switch the read to preserve plan order.flag_config_versionmust match the live flag configuration version; the acceptance test reads it from the created flag's environment config.Test plan
go build ./...✅go vet ./launchdarkly/✅gofmt/gofmtsclean (incl.keys.gosorted block) ✅go generate .(docs + examples) committed ✅go test ./scripts/driftreport/✅ (mapping.yaml parses, no drift for Experiments)TestAccExperiment_CreateUpdate,TestAccExperimentationSettings_CreateUpdate,TestAccDataSourceExperimentationSettings_basic(require a real enterprise account; not run in this push).🤖 Generated with Claude Code