-
Notifications
You must be signed in to change notification settings - Fork 123
Fix null value handling in Kibana connector config causing inconsistent apply state #1524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: tobio <444668+tobio@users.noreply.github.com>
Co-authored-by: tobio <444668+tobio@users.noreply.github.com>
Co-authored-by: tobio <444668+tobio@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where the elasticstack_kibana_action_connector resource fails with "Provider produced inconsistent result after apply" when null values (e.g., headers = null) are present in the connector configuration JSON. The fix ensures that null values are recursively removed from the configuration before state comparison, preventing state mismatches.
Key Changes:
- Added recursive null value removal to the
SanitizedValue()function via a newremoveNulls()helper - Added comprehensive unit tests covering various null value scenarios
- Added acceptance test steps to verify null value handling in real-world scenarios
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
internal/kibana/connectors/config_value.go |
Added removeNulls() helper function and integrated it into SanitizedValue() to recursively remove null values from configuration maps |
internal/kibana/connectors/config_value_test.go |
Added 5 new unit test cases covering null value removal in top-level, nested, mixed, all-null, and combined scenarios |
internal/kibana/connectors/acc_test.go |
Added new acceptance test step with null headers and fixed regex escaping for consistency |
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorCasesWebhook/with_predefined_connector_id/null_headers/connector.tf |
New test configuration file with headers = null for predefined connector ID test case |
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorCasesWebhook/with_empty_connector_id/null_headers/connector.tf |
New test configuration file with headers = null for empty connector ID test case |
|
@copilot add an entry to |
Co-authored-by: tobio <444668+tobio@users.noreply.github.com>
Done in 69ff68b. Added CHANGELOG entry under the Unreleased section describing the fix for null value handling in |
CHANGELOG.md
Outdated
|
|
||
| ### Changes | ||
|
|
||
| - Fix `elasticstack_kibana_action_connector` failing with "inconsistent result after apply" when config contains null values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Be consistent with the other changelog entries.
| - Fix `elasticstack_kibana_action_connector` failing with "inconsistent result after apply" when config contains null values | |
| - Fix `elasticstack_kibana_action_connector` failing with "inconsistent result after apply" when config contains null values ([#1524](https://github.com/elastic/terraform-provider-elasticstack/pull/1524)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 36df21d. Updated the CHANGELOG entry to include the PR number reference for consistency with other entries.
Co-authored-by: tobio <444668+tobio@users.noreply.github.com>
* origin/main: Fixup changelog Bump release disk size Prepare 0.13.0 release (#1532) Fix null value handling in Kibana connector config causing inconsistent apply state (#1524) Add Security List Data Stream Resource (#1525) chore(deps): update golang:1.25.5 docker digest to 0ece421 (#1531) Fleet agent policy host name format field (#1521) chore(deps): update kibana-openapi-spec digest to 6647f81 (#1528) chore(deps): update kibana-openapi-spec digest to bd3d07c (#1519)
Plan to fix null value handling in Kibana connector config
SanitizedValue()function to remove null entries from top-level fieldsSanitizedValue()to recursively remove null entries from nested mapsconfig_value_test.goTestAccResourceKibanaConnectorCasesWebhookto test null headersSummary
This PR fixes a bug where the
elasticstack_kibana_action_connectorresource fails with "Provider produced inconsistent result after apply" when the config JSON includes null values (e.g.,headers = null).Root Cause
When users provide
headers = null(or any other null field) in the connector config JSON, the Terraform provider would:Solution
Updated the
SanitizedValue()function to recursively remove all null values from the config map before marshaling it back to JSON. This ensures that null values are removed from both the planned and actual state, preventing state mismatches.Changes Made
Code Changes:
removeNulls()helper function that recursively removes null values from mapsSanitizedValue()to callremoveNulls()after removing the connector type ID keyremoveNulls()to use explicit continue statements for better code clarityTests Added:
headers = nullto verify end-to-end functionalityDocumentation:
All Tests Pass:
Security Summary
No security vulnerabilities were introduced or discovered during this change.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.