Skip to content

fix: skip auto-named defaults that trigger upstream ConflictsWith - #3457

Merged
iwahbe merged 2 commits into
mainfrom
iwahbe/fix-auto-name-conflicts-with
May 26, 2026
Merged

fix: skip auto-named defaults that trigger upstream ConflictsWith#3457
iwahbe merged 2 commits into
mainfrom
iwahbe/fix-auto-name-conflicts-with

Conversation

@iwahbe

@iwahbe iwahbe commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

The dynamic bridge runs SetAutonaming against every wrapped provider, which attaches an AutoName default to any property literally called name. During Check, defaults.ApplyDefaultInfoValues fires that default whenever the user omits name, populating it with a generated value before forwarding to the upstream provider's ValidateResourceConfig.

For providers like aws_cloudwatch_log_group whose name and name_prefix are Optional + Computed + ConflictsWith: each other, the injected name collides with the user-supplied name_prefix and SDKv2 returns two "Conflicting configuration arguments" diagnostics. The protocol-level schema doesn't surface ConflictsWith, so the bridge can't anticipate the conflict.

This change detects the case after the first ValidateResourceConfig call: if a ConflictsWith diagnostic targets an attribute the bridge auto-named, strip the auto-default from the inputs and re-validate once. The cleaned inputs are also returned from Check so the property doesn't leak into state — the upstream SDK will compute the final name from name_prefix during plan/apply, matching tofu's behavior.

Fixes #1095

Test plan

  • New TestConflictsWithNamePrefixOnly in dynamic/conflicting_test.go reproduces the failure and now passes (check + create subtests).
  • Existing pkg/pf/tfbridge unit tests still pass.
  • CI green on this branch.

The dynamic bridge runs `SetAutonaming` against every resource exposed by
a wrapped provider, which attaches an `AutoName` default to any property
literally called `name`. During Check, `defaults.ApplyDefaultInfoValues`
fires that default whenever the user omits `name`, populating it with a
generated `<urn-name>-<random>` value before the inputs are forwarded to
the upstream provider's `ValidateResourceConfig`.

For providers like `aws_cloudwatch_log_group` that expose `name` and
`name_prefix` as `Optional + Computed + ConflictsWith: each other`, the
injected `name` collides with the user-supplied `name_prefix` and the
SDKv2 server returns two "Conflicting configuration arguments"
diagnostics. The protocol-level schema does not surface `ConflictsWith`,
so the bridge cannot know about the conflict ahead of time.

Detect this case after the first `ValidateResourceConfig` call: if a
ConflictsWith diagnostic points at an attribute the bridge auto-named,
strip the auto-default from the inputs and re-validate once. The cleaned
inputs are also returned from Check so the property does not leak into
state — the upstream SDK will compute the final `name` from
`name_prefix` during plan/apply, matching tofu's behaviour.
@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 43.58974% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.85%. Comparing base (26e6220) to head (7a772e5).

Files with missing lines Patch % Lines
dynamic/test/conflictsprovider/main.go 0.00% 31 Missing ⚠️
pkg/pf/tfbridge/provider_check.go 72.34% 8 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3457      +/-   ##
==========================================
+ Coverage   69.82%   69.85%   +0.03%     
==========================================
  Files         347      348       +1     
  Lines       38011    38083      +72     
==========================================
+ Hits        26541    26603      +62     
+ Misses       9661     9660       -1     
- Partials     1809     1820      +11     

☔ View full report in Codecov by Sentry.
📢 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.

Add TestConflictsWithBothUserSpecified to verify that the
auto-defaulted-conflict-stripper does not swallow the upstream
ConflictsWith diagnostics when the user explicitly sets both
`name` and `name_prefix`. The bridge must still report both
SDKv2 "Conflicting configuration arguments" failures so the
user can correct their program.
@iwahbe
iwahbe marked this pull request as ready for review May 26, 2026 18:43
@iwahbe
iwahbe requested a review from a team May 26, 2026 18:43
@iwahbe iwahbe self-assigned this May 26, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No actionable issues found.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

Reviewed by Internal Trusted PR Reviewer

To install this agentic workflow, run

gh aw add pulumi-labs/gh-aw-internal/.github/workflows/gh-aw-pr-review.md@8a92f53fac170563f7727cacab2dbedb5d5b9e29

@iwahbe
iwahbe merged commit 18aa72d into main May 26, 2026
79 checks passed
@iwahbe
iwahbe deleted the iwahbe/fix-auto-name-conflicts-with branch May 26, 2026 19:05
continue
}
pk := resource.PropertyKey(tfbridge.TerraformToPulumiNameV2(tfKey, schemaMap, schemaInfos))
if _, inUser := inputs[pk]; inUser {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't matter for dynamically bridged providers, as they don't have preCheck callbacks, but on regular bridged providers shouldn't we use the checked inputs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes

@iwahbe iwahbe mentioned this pull request May 27, 2026
iwahbe added a commit that referenced this pull request May 27, 2026
Fixes the bug introduced in
#3457 as pointed
out by @guineveresaenger: we no longer drop insertions added by
`PreCheckCallback`.
@pulumi-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped in release v3.131.0.

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.

Validation-aware defaults application for Plugin Framework based providers

4 participants