Skip to content

Reproduce PF nested set value crossing - #3572

Draft
corymhall wants to merge 1 commit into
mainfrom
repro/pf-set-element-correlation-1249
Draft

Reproduce PF nested set value crossing#3572
corymhall wants to merge 1 commit into
mainfrom
repro/pf-set-element-correlation-1249

Conversation

@corymhall

Copy link
Copy Markdown
Member

Pulumi can cross nested Optional+Computed values between elements of a Plugin Framework SetNestedBlock during create. In the Datadog SpansMetric case, this silently assigns explicit tag_name values to the wrong group_by paths.

The proposed state canonicalizes the set, while the PF config keeps the Pulumi source-array order. The Plugin Framework walks planned set elements but obtains each config element by the same numeric index. When a nested attribute plan modifier runs, it can therefore read a value from one config element and write it into another planned element.

This draft adds a focused Terraform/Pulumi create cross-test. The existing helper derives Pulumi input from cty.SetVal, which canonicalizes the set and masks the bug. The new option lets the test preserve the original Pulumi input order.

The test currently fails as intended:

                 Terraform plan     Pulumi plan
@stream.tag_name "stream"           "stream"
@tier.tag_name   "tier"             "tier"
service.tag_name unknown             "stream"
status.tag_name  unknown             "tier"

A later change can use this test to verify the runtime fix. This PR does not propose that fix yet.

Downstream: pulumi/pulumi-datadog#1249

Validation:

  • go test ./pkg/pf/tests/internal/cross-tests -count=1 passes.
  • make test RUN_TEST_CMD='./pkg/pf/tests -run ^TestPFCreateSetNestedBlockPreservesElementCorrelation$ -count=1' fails at the plan comparison as intended. Pulumi assigns stream to service and tier to status.

Summary:
- allow PF create cross-tests to provide explicit Pulumi input order
- add a create parity test for optional computed fields in nested sets

Rationale:
- deriving Pulumi input from cty.SetVal canonicalizes the set and masks the
  config-to-plan ordering bug
- the red test captures the Datadog SpansMetric value crossing without
  provider-specific API behavior

Tests:
- go test ./pkg/pf/tests/internal/cross-tests -count=1
- make test RUN_TEST_CMD='./pkg/pf/tests -run
  ^TestPFCreateSetNestedBlockPreservesElementCorrelation$ -count=1'
  (fails as intended: Pulumi crosses stream/tier onto service/status)
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.48%. Comparing base (59de6c6) to head (cf51deb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3572      +/-   ##
==========================================
- Coverage   70.49%   70.48%   -0.02%     
==========================================
  Files         358      358              
  Lines       39484    39484              
==========================================
- Hits        27834    27830       -4     
- Misses       9703     9705       +2     
- Partials     1947     1949       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant