@@ -152,13 +152,33 @@ func (f *Function) handleApprovedChanges(req *fnv1.RunFunctionRequest, in *v1bet
152152 return err
153153 }
154154
155- // For approved changes, we need to ensure we properly handle both
156- // the composite resource and composed resources to avoid duplication
155+ // For approved changes, we need to properly pass through the entire desired state
156+ // from the previous function, including both the XR and composed resources
157157
158- // Keep only the composed resources, not the main XR (which is handled via saveOldHash)
159- // This avoids duplication in the render output
160- if req .GetDesired ().GetResources () != nil {
161- rsp .Desired .Resources = req .GetDesired ().GetResources ()
158+ // Get the desired composite resource
159+ dxr , err := request .GetDesiredCompositeResource (req )
160+ if err != nil {
161+ response .Fatal (rsp , errors .Wrap (err , "cannot get desired composite resource" ))
162+ return err
163+ }
164+
165+ // Set the desired composite resource in the response
166+ if err := response .SetDesiredCompositeResource (rsp , dxr ); err != nil {
167+ response .Fatal (rsp , errors .Wrapf (err , "cannot set desired composite resource in %T" , rsp ))
168+ return err
169+ }
170+
171+ // Get the desired composed resources using the SDK
172+ desired , err := request .GetDesiredComposedResources (req )
173+ if err != nil {
174+ response .Fatal (rsp , errors .Wrapf (err , "cannot get desired resources from %T" , req ))
175+ return err
176+ }
177+
178+ // Set the desired composed resources in the response
179+ if err := response .SetDesiredComposedResources (rsp , desired ); err != nil {
180+ response .Fatal (rsp , errors .Wrapf (err , "cannot set desired composed resources in %T" , rsp ))
181+ return err
162182 }
163183
164184 // Set success condition
0 commit comments