Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where empty string fields in API responses were not being properly handled, causing Terraform apply operations to fail after manual UI updates. The fix introduces new type utility functions to treat empty strings as null values, ensuring consistent state management between Terraform and the API.
Key changes:
- New utility functions
NonEmptyStringValueandNonEmptyStringPointerValueto convert empty strings to null - Updated SSL configuration handling to return null objects when all fields are empty
- Added validators to ensure required SSL fields are non-empty
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/utils/typeutils/string.go | Added utility functions to convert empty strings to null values |
| internal/fleet/output/schema.go | Added validators to ensure SSL certificate fields are non-empty |
| internal/fleet/output/models_ssl_test.go | Added test cases for empty SSL field handling |
| internal/fleet/output/models_ssl.go | Updated SSL model conversion to use new utilities and handle empty fields |
| internal/fleet/output/models_logstash.go | Applied empty string handling to CaTrustedFingerprint field |
| internal/fleet/output/models_kafka.go | Applied empty string handling to CaTrustedFingerprint field |
| internal/fleet/output/models_elasticsearch.go | Applied empty string handling to CaTrustedFingerprint field |
| internal/elasticsearch/ml/anomaly_detection_job/models_tf.go | Replaced verbose empty string checks with new utility functions throughout ML model conversions |
| internal/elasticsearch/index/alias/models.go | Applied empty string handling to routing fields |
nick-benoit
approved these changes
Dec 4, 2025
Contributor
nick-benoit
left a comment
There was a problem hiding this comment.
Nice. Its good to see so many of those if / else empty string checks disappear.
tobio
added a commit
to tehbooom/terraform-provider-elasticstack
that referenced
this pull request
Dec 8, 2025
* origin/main: (170 commits) Add required_versions attribute to fleet_agent_policy for automatic agent upgrades (elastic#1436) docs: webhook action connector (elastic#1518) Migrate elasticstack_elasticsearch_security_role resource to Plugin Framework (elastic#1331) chore(deps): update module github.com/golangci/golangci-lint to v2.7.1 (elastic#1516) chore(deps): update kibana-openapi-spec digest to 38106c2 (elastic#1517) Bundle POC dashboard schema into the Kibana API client (elastic#1514) chore(deps): update golang docker tag to v1.25.5 (elastic#1505) Ignore empty fields in API response (elastic#1506) Migrate fleet output acceptance tests (elastic#1509) chore(deps): update golangci/golangci-lint-action digest to 1e7e51e (elastic#1507) Expose experimental resources in acceptance tests (elastic#1512) Use docker.elastic.co for elastic-agent images (elastic#1513) chore(deps): update module github.com/golangci/golangci-lint to v2.7.0 (elastic#1515) fix(deps): update module github.com/hashicorp/terraform-plugin-testing to v1.14.0 (elastic#1510) chore(deps): update docker.elastic.co/kibana/kibana docker tag to v9.2.2 (elastic#1504) chore(deps): update actions/checkout digest to 8e8c483 (elastic#1503) Bump es memory to 4g (elastic#1511) Add security exception item (elastic#1496) Bump test timeouts fix(deps): update module github.com/hashicorp/terraform-plugin-framework to v1.17.0 (elastic#1508) ...
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.
Fixes #836
Introduces some new type helpers for the case where we want to treat an empty string as null.
To reproduce the original bug:
terraform applyThe current provider version will error, this PR will not. It's hard to create an acceptance test around this behaviour since it requires editing the output via the UI (I suppose I could have a test that modified the output directly via the API).