feat: Add support for AI Configs and Segment approval settings in environment resource#389
Draft
feat: Add support for AI Configs and Segment approval settings in environment resource#389
Conversation
- Add validation that errors when service_kind (non-default) or service_config are used with resource_kind segment/aiconfig - Update schema descriptions to document the constraint - Add comprehensive test coverage (7 new test functions) - Update CHANGELOG and migration documentation - Generate updated provider documentation These fields are only supported for flag approval settings. Previously they were silently ignored for segment/aiconfig, which could lead to unexpected behavior.
- Add positive test for multi-resource approval settings (flag + segment) - Add negative test for invalid service_kind with segment resource - Add negative test for invalid service_config with segment resource - All tests include ImportState verification - Tests validate error messages match expected patterns
ldhenry
commented
Feb 19, 2026
Contributor
Author
There was a problem hiding this comment.
This file should either be moved to the docs dir or removed altogether.
ldhenry
commented
Feb 19, 2026
The API returns default approval settings for segment and aiconfig resources even when not explicitly configured by the user. This was causing Terraform to detect drift and try to remove these unconfigured settings. This commit filters out segment/aiconfig approval settings that are not actually configured (i.e., where required=false and requiredApprovalTags is empty). The filtering is done inline within environmentApprovalSettingsToResourceData() following the pattern used in targetsToResourceData(). Flag approval settings are always included for backwards compatibility.
When approval_settings is not configured by the user, config[APPROVAL_SETTINGS]
returns nil. The previous code tried to do a type assertion on nil interface{}
to []interface{} which causes a panic.
This fix:
- Changes approvalPatchFromSettings signature to accept []interface{}
directly instead of interface{}
- Adds nil checks before type assertions in environments_helper.go
- Adds nil checks in resource_launchdarkly_environment.go
Fixes the "Unsupported json-patch operation" error in
TestAccProject_CSA_Update_And_Revert by preventing panics when
approval_settings is not configured.
Note: Schema Default values on fields within Optional blocks do NOT
cause terraform to instantiate blocks, so keeping all existing defaults.
- Remove unused approvalSettingsFromResourceData - Remove unused approvalSettingsToResourceData - Remove unused getApprovalSettingByKind - Fix S1009: omit unnecessary nil checks before len()
Per @ldhenry feedback - migration guides belong in docs/guides/
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.
Originally created by @tarqd. We still need to decide if this is the right approach. More information on Slack here.
approval_settingsthat produces an error whenservice_kind(with non-default value) orservice_configare used withresource_kindvalues other than"flag". These fields are only supported for flag approval settings. Previously, these fields were silently ignored for segment and aiconfig approval settings, which could lead to unexpected behavior.