Skip to content

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

Merged
jakubramut merged 2 commits into
mainfrom
fix/kcl-oxr-conditions-type
Jul 27, 2026
Merged

fix(kcl): avoid full OXR cast to prevent conditions type error#176
jakubramut merged 2 commits into
mainfrom
fix/kcl-oxr-conditions-type

Conversation

@kaessert

Copy link
Copy Markdown
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

@jakubramut jakubramut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jakubramut
jakubramut merged commit 8fe6c61 into main Jul 27, 2026
4 of 7 checks passed
@jakubramut
jakubramut deleted the fix/kcl-oxr-conditions-type branch July 27, 2026 14:28
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.

2 participants