Repository: pulumi/pulumi (go)

Issue:
The `parent` resource option is undefined inside a transform
`parent` is always `undefined` inside `registerResourceTransform` (Node.js).

It looks like the engine isn't passing this through.

Pull request description:
Fix sending parent in resource transforms
Fixes #18643

The engine wasn't filling in the parent URN for resource transform requests. Looks like all the SDKs already have the code to receive this.

Patch:
diff --git a/changelog/pending/20250219--engine--send-parent-urn-to-resource-transforms.yaml b/changelog/pending/20250219--engine--send-parent-urn-to-resource-transforms.yaml
new file mode 100644
index 0000000000..a1c1cd16d4
--- /dev/null
+++ b/changelog/pending/20250219--engine--send-parent-urn-to-resource-transforms.yaml
@@ -0,0 +1,4 @@
+changes:
+- type: fix
+  scope: engine
+  description: Send parent URN to resource transforms
diff --git a/pkg/resource/deploy/source_eval.go b/pkg/resource/deploy/source_eval.go
index e1929dd1a1..b6bbcb6580 100644
--- a/pkg/resource/deploy/source_eval.go
+++ b/pkg/resource/deploy/source_eval.go
@@ -1432,6 +1432,7 @@ func (rm *resmon) wrapTransformCallback(cb *pulumirpc.Callback) (TransformFuncti
 		request, err := proto.Marshal(&pulumirpc.TransformRequest{
 			Name:       name,
 			Type:       typ,
+			Parent:     string(parent),
 			Custom:     custom,
 			Properties: mprops,
 			Options:    opts,


Test patch:
diff --git a/pkg/engine/lifecycletest/transformation_test.go b/pkg/engine/lifecycletest/transformation_test.go
index 0f3b52becf..b3b690dd88 100644
--- a/pkg/engine/lifecycletest/transformation_test.go
+++ b/pkg/engine/lifecycletest/transformation_test.go
@@ -394,6 +394,7 @@ func TestRemoteTransformationsConstruct(t *testing.T) {
 				props resource.PropertyMap, opts *pulumirpc.TransformResourceOptions,
 			) (resource.PropertyMap, *pulumirpc.TransformResourceOptions, error) {
 				if typ == "pkgA:m:typA" {
+					assert.Equal(t, "urn:pulumi:test::test::pkgA:m:typC::resC", parent)
 					props["foo"] = pvApply(props["foo"], func(v resource.PropertyValue) resource.PropertyValue {
 						return resource.NewNumberProperty(v.NumberValue() + 1)
 					})
@@ -773,7 +774,6 @@ func TestTransformsProviderOpt(t *testing.T) {
 			TransformFunction(func(name, typ string, custom bool, parent string,
 				props resource.PropertyMap, opts *pulumirpc.TransformResourceOptions,
 			) (resource.PropertyMap, *pulumirpc.TransformResourceOptions, error) {
-				fmt.Println("provider: ", opts.Provider)
 				if opts.Provider == "" {
 					opts.Provider = implicitProvider
 				}