Skip to content

fix(kcl): avoid full OXR cast to prevent conditions type error#176

Open
kaessert wants to merge 1 commit intomainfrom
fix/kcl-oxr-conditions-type
Open

fix(kcl): avoid full OXR cast to prevent conditions type error#176
kaessert wants to merge 1 commit intomainfrom
fix/kcl-oxr-conditions-type

Conversation

@kaessert
Copy link
Contributor

Summary

  • Use partial cast pattern for OXR deserialization in cluster function: keep raw oxr and cast only spec.parameters to the typed model
  • Prevents EvaluationError on status.conditions where the auto-generated KCL model expects a typed list but Crossplane passes a generic list at runtime

Details

The auto-generated KCL model types status.conditions as [SpecificConditionType], but Crossplane populates it as a generic JSON list at runtime. Full OXR casting (oxr = Type{**option("params").oxr}) includes this field, causing:

EvaluationError: conditions?: [TypedList] — expect [...], got list

The fix follows the proven pattern from configuration-azure-aks v0.16.0:

# Before (fails):
oxr = platformrefv1alpha1.Cluster{**option("params").oxr}

# After (works, preserves type safety on parameters):
oxr = option("params").oxr
_params = platformrefv1alpha1.Cluster.spec.parameters{**oxr.spec?.parameters}

Test plan

  • up project build succeeds
  • Deploy on Crossplane v2 control plane and verify XCluster reconciles without KCL errors

The auto-generated KCL model types status.conditions as a typed list
(e.g. [ClusterStatusConditionsItems0]) which is incompatible with the
generic list that Crossplane passes at runtime. This causes a fatal
EvaluationError on every reconciliation after the first (once Crossplane
populates the XR status conditions).

Fix by keeping the raw OXR dict and casting only spec.parameters to the
typed schema, following the pattern used in configuration-azure-aks.
This preserves type safety for parameter access while avoiding the
conditions type mismatch.
@kaessert kaessert requested a review from a team as a code owner February 25, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant