Crossplane PatchAndTransform error in CI
function-patch-and-transform copies and transforms values between the XR and composed resources. A patch fails when the source path is missing, a transform cannot convert the value, or the destination path is invalid, and the resource is not rendered.
What this error means
The XR reports a compose error mentioning a patch index and a transform, such as "cannot convert" or "cannot get value from field path", and the composed resource never appears.
cannot compose resources: cannot render composed resource "bucket":
cannot apply patch at index 1: cannot convert value "large" to int64:
strconv.ParseInt: parsing "large": invalid syntaxCommon causes
A transform cannot convert the value
A convert or math transform receives a value of the wrong type (a string where a number is expected), so the patch fails.
The source field path does not exist
The patch reads fromFieldPath a field the XR does not set, so there is no value to transform or write.
How to fix it
Map the value or fix the type
- Read the patch index and transform in the error.
- Use a map transform for enum-like inputs, or coerce the type before convert.
- Render locally to confirm the patch now succeeds.
- type: FromCompositeFieldPath
fromFieldPath: spec.size
toFieldPath: spec.forProvider.sizeGb
transforms:
- type: map
map: {small: "10", large: "100"}Guard optional source fields
Set the patch policy so a missing optional source does not fail the whole render.
- type: FromCompositeFieldPath
fromFieldPath: spec.region
toFieldPath: spec.forProvider.region
policy:
fromFieldPath: OptionalHow to prevent it
- Render compositions in PR to catch patch and transform errors early.
- Use map transforms for enum inputs instead of raw conversions.
- Mark optional source paths Optional so absence does not fail the render.