Skip to content
Latchkey

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.

crossplane
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 syntax

Common 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

  1. Read the patch index and transform in the error.
  2. Use a map transform for enum-like inputs, or coerce the type before convert.
  3. Render locally to confirm the patch now succeeds.
composition.yaml
- 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.

composition.yaml
- type: FromCompositeFieldPath
  fromFieldPath: spec.region
  toFieldPath: spec.forProvider.region
  policy:
    fromFieldPath: Optional

How 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.

Frequently asked questions

What causes "PatchAndTransform patch error"?
A convert or math transform receives a value of the wrong type (a string where a number is expected), so the patch fails.
How do I fix PatchAndTransform patch error?
Map the value or fix the type

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card