Conversation
- Add field_attrs to basic_updated testdata to prevent RequiresReplace - Add captureID/checkIDUnchanged helpers to verify in-place update - Assert runtime_field_map is preserved across basic -> basic_updated step - Ignore runtime_field_map in import state verify since config omits it
…d and persisted API value scenario
|
✅ PR Changelog Check passed — the |
ApprovabilityVerdict: Approved This is a focused bug fix that adds You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Pull request overview
Fixes Terraform state consistency drift for data_view.runtime_field_map when the attribute is omitted from config but Kibana returns/preserves runtime fields.
Changes:
- Mark
data_view.runtime_field_mapasOptional+Computedin the provider schema to prevent planned-vs-actual inconsistencies. - Update acceptance coverage to assert an in-place update (no recreation) while Kibana preserves
runtime_field_mapafter it’s removed from config. - Extend REQ-011 to explicitly describe persisted non-empty behavior when
runtime_field_mapis omitted.
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 |
|---|---|
| openspec/specs/kibana-data-view/spec.md | Updates schema excerpt and REQ-011 to document Optional+Computed and persisted runtime field behavior. |
| openspec/changes/fix-dataview-runtime-field-map-state/tasks.md | Marks the change tasks as completed and records the validation steps run. |
| internal/kibana/dataview/testdata/TestAccResourceDataView/basic_updated/data_view.tf | Aligns field_attrs so the “updated” step remains an in-place update. |
| internal/kibana/dataview/schema.go | Sets Computed: true on runtime_field_map to eliminate state consistency errors when omitted from config. |
| internal/kibana/dataview/acc_test.go | Adds ID capture/unchanged checks and asserts runtime fields persist when removed from config; adjusts import verification accordingly. |
| ### Requirement: State mapping for empty collections (REQ-011) | ||
|
|
||
| When mapping API responses back to Terraform state, empty `source_filters`, `field_attrs`, `runtime_field_map`, and `field_formats` returned by Kibana SHALL preserve a prior null value instead of forcing an empty list or map into state. If a field format entry has no `params`, the resource SHALL store `params` as a null object in state. | ||
| When mapping API responses back to Terraform state, empty `source_filters`, `field_attrs`, `runtime_field_map`, and `field_formats` returned by Kibana SHALL preserve a prior null value instead of forcing an empty list or map into state. If a field format entry has no `params`, the resource SHALL store `params` as a null object in state. `runtime_field_map` SHALL be marked `Optional` and `Computed` so that it remains user-settable while Terraform also accepts a persisted non-empty value when the attribute is omitted from configuration. |
There was a problem hiding this comment.
Requirements verification (REQ-011): The updated requirement appears internally consistent with the schema section, and the implementation matches it. runtime_field_map is now Optional+Computed in internal/kibana/dataview/schema.go, and populateFromAPI preserves prior nulls for empty API maps/lists, which aligns with the “preserve prior null” behavior while allowing a persisted non-empty runtime_field_map when omitted from config.
There was a problem hiding this comment.
OpenSpec verification: fix-dataview-runtime-field-map-state
Disposition reason: every file under the selected change is a modification, so APPROVE is permitted when verification finds zero CRITICAL issues and zero unassociated files.
Summary
| Dimension | Status |
|---|---|
| Completeness | 11/11 tasks complete; 1 modified requirement reviewed |
| Correctness | REQ-011 implementation and scenario coverage match the change |
| Coherence | Implementation follows the documented design |
Issues by priority
- CRITICAL: none
- WARNING: none
- SUGGESTION: none
Verification notes
internal/kibana/dataview/schema.go:127marksdata_view.runtime_field_mapasOptional+Computed, matching updated REQ-011.internal/kibana/dataview/acc_test.go:49andinternal/kibana/dataview/testdata/TestAccResourceDataView/basic_updated/data_view.tf:23now keep the update path in-place and assert Kibana preservesruntime_field_mapwhile resource identity stays stable.openspec/specs/kibana-data-view/spec.md:30andopenspec/specs/kibana-data-view/spec.md:215align the canonical spec with the delta spec.
Out-of-scope / unassociated changes
- Unassociated: none
- Uncertain: none
- Relevant outside the structural allowlist:
internal/kibana/dataview/schema.go,internal/kibana/dataview/acc_test.go, andinternal/kibana/dataview/testdata/TestAccResourceDataView/basic_updated/data_view.tfare directly required by the proposal/design/tasks for this change.
CI status considered
I did not run tests. Current PR checks show Build and Lint passing. Multiple acceptance and CodeQL jobs are still in progress, so I am leaving a COMMENT review rather than approving at this point.
Generated by OpenSpec verify (label) for issue #2592 · ● 7.2K
Kibana's partial-update API preserves unspecified fields. When these fields are omitted from configuration after being previously set, Terraform rejects the preserved API value because they were Optional without Computed. Adding Computed: true allows Terraform to accept the persisted values without raising a consistency error. This is the same fix previously applied to runtime_field_map.
…ource_filters The basic_updated step now verifies that field_formats and source_filters are preserved by Kibana during in-place update, instead of asserting they are absent. Also adds these fields to ImportStateVerifyIgnore since they are Computed and may differ between config and state.
…REQ-011 Updates the schema documentation and adds scenarios covering omitted configuration with preserved API values for field_formats and source_filters, matching the runtime_field_map behavior.
Dismissing prior approval to re-evaluate ca70283
|
Run: https://github.com/elastic/terraform-provider-elasticstack/actions/runs/25200672461 |
Dismissing prior approval to re-evaluate d7bfa85
Dismissing prior approval to re-evaluate 5651ef5
Dismissing prior approval to re-evaluate c1a3451
Fixes the Terraform state consistency error for
runtime_field_mapwhen it is omitted from config but Kibana preserves it.Changes
data_view.runtime_field_mapasComputedin schemaChangelog
Customer impact: fix
Summary: Fix state consistency error when runtime_field_map is omitted from configuration after previously being set
Testing
make build: PASSgo test ./internal/kibana/dataview/...: PASSmake check-lint: PASSNote
Fix
runtime_field_map,field_formats, andsource_filtersconsistency inelasticstack_kibana_data_viewdata_view.runtime_field_map,data_view.field_formats, anddata_view.source_filtersasComputed: truewithUseStateForUnknownplan modifiers in schema.go, so Terraform preserves Kibana-persisted values when these attributes are omitted from config.Macroscope summarized c1a3451.