generated from crossplane/function-template-go
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
When setting the status using option("params").dxr, the generated status.conditions is sometimes set to null instead of an empty array when no conditions are present. This causes an error in Crossplane claims, as the field expects an array, not null. Specifically, the error reported is:
Warning ComposeResources 107s (x27 over 29m) defined/compositeresourcedefinition.apiextensions.crossplane.io cannot compose resources: cannot apply composite resource status: XProject.platform.eng.it "platform-gxbnm" is invalid: status.conditions: Invalid value: "null": conditions in body must be of type array: "null"
How can we reproduce it?
- In a composition using function-kcl, set status via:
dxr = option("params").dxr _dxr.status = { somekey = "somevalue" } - Alternatively, try merging status into dxr:
dxr = option("params").dxr _dxr = { **option("params").dxr status.somekey = "somevalue" } - In both cases, if no conditions are present, observe that
status.conditionsis set to null. - Apply the composition and observe the error in Crossplane claims.
What environment did it happen in?
Function version: v0.11.1
Crossplane version: v1.20.1
Kubernetes version: 1.32
Distribution/OS: (please specify)
Related issues and PRs:
- KCL schema initialisation merges array fields with a default value instead of overriding them #275 (array merging during schema initialization, empty arrays)
- [Enhancement] setting composition resource status #60 (status fields in compositions)
- kcl-lang#1763 (null handling during JSON decode)
- PR #187 and related issue
Expected behavior:
status.conditionsshould always be an array (possibly empty), never null.
Workaround / Notes:
- The recommended approach is to set status via
option("params").dxr, but further handling is needed to ensure arrays are notnull.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working