Skip to content

[Fix] Allow child resources to override parent's protect setting#2156

Merged
iwahbe merged 3 commits into
pulumi:mainfrom
addu390:fix/java-child-protect-override
May 12, 2026
Merged

[Fix] Allow child resources to override parent's protect setting#2156
iwahbe merged 3 commits into
pulumi:mainfrom
addu390:fix/java-child-protect-override

Conversation

@addu390
Copy link
Copy Markdown
Contributor

@addu390 addu390 commented May 2, 2026

Summary

Allow a child resource to override its parent's protect setting in the Java SDK.

This PR:

  • Changes the field to @Nullable Boolean so explicit false is distinguishable.
  • Adds a protect(@Nullable Boolean) builder overload, existing .protect(true) / .protect(false) calls work as-is.
  • Child wins when explicitly set, otherwise inherit from parent.

Fixes the Java side of pulumi/pulumi#18935. Matches the Go fix in pulumi/pulumi#18862 pulumi/pulumi#18924.

Questions

  1. Should this be coordinated with the pending Go fix in #18935?
  2. Similar bug exists for retainOnDelete. Good to fold it into this one?

@addu390 addu390 requested a review from a team as a code owner May 2, 2026 22:33
@addu390
Copy link
Copy Markdown
Contributor Author

addu390 commented May 2, 2026

@Frassle Your take on how to best go about releasing this in the Java SDK?

@@ -370,7 +382,7 @@ public Output<List<Resource>> getDependsOn() {
* @see Builder#protect(boolean)
*/
public boolean isProtect() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is what's actually used to set the RegisterResource request, so I think we need another method here "isProtectNullable"(?) to check in the register resource code to work out if we should actually send true, false, or null to the engine.

Also it would be good to get the l2-resource-parent-inheritance test passing with this change, even if it requires a manually written program file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Frassle Went with Optional<Boolean> getProtect() instead, similar to the other Optional<> getters.

And for the test: retainOnDelete needed the same tri-state fix to make it pass, and while in there, deleteBeforeReplace had the same bug. Saw your draft in #1956 was heading the same way, so applied the pattern across all three.

Tests passed locally.

@addu390 addu390 requested a review from Frassle May 3, 2026 21:24
@addu390
Copy link
Copy Markdown
Contributor Author

addu390 commented May 11, 2026

Hi @Frassle, no rush, but could you review when you get a chance. Was hoping to get the fix deployed for Java users.

Copy link
Copy Markdown
Member

@Frassle Frassle left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me, just get a changelog added and we can merge

@addu390
Copy link
Copy Markdown
Contributor Author

addu390 commented May 11, 2026

Looks reasonable to me, just get a changelog added and we can merge

Thank you. Added the change-log.

@iwahbe iwahbe enabled auto-merge (squash) May 12, 2026 09:05
@iwahbe iwahbe merged commit 4707906 into pulumi:main May 12, 2026
13 checks passed
@pulumi-bot
Copy link
Copy Markdown
Contributor

This PR has been shipped in release v1.27.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.

4 participants