Skip to content

Fix runtime_field_map consistency issue#2592

Open
tobio wants to merge 11 commits intomainfrom
runtime-field-map
Open

Fix runtime_field_map consistency issue#2592
tobio wants to merge 11 commits intomainfrom
runtime-field-map

Conversation

@tobio
Copy link
Copy Markdown
Member

@tobio tobio commented May 1, 2026

Fixes the Terraform state consistency error for runtime_field_map when it is omitted from config but Kibana preserves it.

Changes

  • Mark data_view.runtime_field_map as Computed in schema
  • Update acceptance test to verify true in-place update behavior (not replacement)
  • Update REQ-011 requirement to cover persisted-null behavior

Changelog

Customer impact: fix
Summary: Fix state consistency error when runtime_field_map is omitted from configuration after previously being set

Testing

  • make build: PASS
  • go test ./internal/kibana/dataview/...: PASS
  • make check-lint: PASS
  • Acceptance tests require a running Kibana stack

Note

Fix runtime_field_map, field_formats, and source_filters consistency in elasticstack_kibana_data_view

  • Marks data_view.runtime_field_map, data_view.field_formats, and data_view.source_filters as Computed: true with UseStateForUnknown plan modifiers in schema.go, so Terraform preserves Kibana-persisted values when these attributes are omitted from config.
  • Updates the acceptance test to assert specific persisted values for these attributes, verify the resource is updated in-place (not recreated), and ignore them during import verification.
  • Behavioral Change: Plans that previously showed a diff or forced replacement when Kibana persisted values for these attributes will now carry forward prior state.

Macroscope summarized c1a3451.

tobio added 5 commits May 1, 2026 11:25
- 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
Copilot AI review requested due to automatic review settings May 1, 2026 01:32
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

PR Changelog Check passed — the ## Changelog section looks good.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 1, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 1, 2026

Approvability

Verdict: Approved

This is a focused bug fix that adds Computed and plan modifiers to three Terraform schema fields to resolve state consistency errors when Kibana preserves field values not in config. The changes are limited to schema attributes, tests, and documentation with clear intent and low risk.

You can customize Macroscope's approvability policy. Learn more.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_map as Optional + Computed in 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_map after it’s removed from config.
  • Extend REQ-011 to explicitly describe persisted non-empty behavior when runtime_field_map is 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.

Comment thread openspec/specs/kibana-data-view/spec.md Outdated
### 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.
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

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.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

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:127 marks data_view.runtime_field_map as Optional + Computed, matching updated REQ-011.
  • internal/kibana/dataview/acc_test.go:49 and internal/kibana/dataview/testdata/TestAccResourceDataView/basic_updated/data_view.tf:23 now keep the update path in-place and assert Kibana preserves runtime_field_map while resource identity stays stable.
  • openspec/specs/kibana-data-view/spec.md:30 and openspec/specs/kibana-data-view/spec.md:215 align 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, and internal/kibana/dataview/testdata/TestAccResourceDataView/basic_updated/data_view.tf are 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

tobio added 3 commits May 1, 2026 11:57
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.
@macroscopeapp macroscopeapp Bot dismissed their stale review May 1, 2026 01:58

Dismissing prior approval to re-evaluate ca70283

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

⚠️ Terraform acceptance tests failed for snapshot stack version 9.4.0-SNAPSHOT.
This failure is non-blocking because snapshot builds are allowed to fail.

Run: https://github.com/elastic/terraform-provider-elasticstack/actions/runs/25200672461

@macroscopeapp macroscopeapp Bot dismissed their stale review May 1, 2026 02:21

Dismissing prior approval to re-evaluate d7bfa85

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 1, 2026
@macroscopeapp macroscopeapp Bot dismissed their stale review May 1, 2026 02:41

Dismissing prior approval to re-evaluate 5651ef5

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 1, 2026
@macroscopeapp macroscopeapp Bot dismissed their stale review May 1, 2026 03:20

Dismissing prior approval to re-evaluate c1a3451

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