Skip to content

Comments

feat: Add support for AI Configs and Segment approval settings in environment resource#389

Draft
ldhenry wants to merge 12 commits intomainfrom
feat/approval-settings-validation
Draft

feat: Add support for AI Configs and Segment approval settings in environment resource#389
ldhenry wants to merge 12 commits intomainfrom
feat/approval-settings-validation

Conversation

@ldhenry
Copy link
Contributor

@ldhenry ldhenry commented Feb 19, 2026

Originally created by @tarqd. We still need to decide if this is the right approach. More information on Slack here.

  • Added validation to approval_settings that produces an error when service_kind (with non-default value) or service_config are used with resource_kind values 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.

tarqd and others added 4 commits February 18, 2026 14:03
- 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 ldhenry changed the title Feat/approval settings validation feat: Add support for AI Configs and Segment approval settings in environment resource Feb 19, 2026
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file should either be moved to the docs dir or removed altogether.

ldhenry and others added 7 commits February 19, 2026 01:24
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/
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