fix: loaded XRD must honor the composite schema#123
Conversation
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
📝 WalkthroughWalkthroughThe ChangesXRD Forwarding to Render Engine
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/crossplane/render/xr/cmd_test.go (1)
488-490: ⚡ Quick winHarden
XRDPassedToEngineby asserting XRD shape, not only non-nil.Line 488 currently validates presence only. Could we also assert a stable field (e.g.,
spec) so the test guarantees the loaded XRD payload is actually forwarded?Suggested assertion tightening
- if req.GetComposite().GetCompositeResourceDefinition() == nil { - t.Error("expected render request to contain the XRD, got nil") - } + xrd := req.GetComposite().GetCompositeResourceDefinition() + if xrd == nil { + t.Fatal("expected render request to contain the XRD, got nil") + } + if _, ok := xrd.GetFields()["spec"]; !ok { + t.Errorf("expected forwarded XRD to include spec, got fields: %v", xrd.GetFields()) + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/crossplane/render/xr/cmd_test.go` around lines 488 - 490, The current test assertion in the XRDPassedToEngine test only validates that GetCompositeResourceDefinition() returns a non-nil value, but does not verify that the actual XRD payload contains expected structure. Enhance the assertion by adding a check for a stable field such as spec on the returned XRD object to ensure the loaded XRD is properly forwarded to the engine. This tightens the test and guarantees the XRD payload shape, not just its presence.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cmd/crossplane/render/xr/cmd_test.go`:
- Around line 488-490: The current test assertion in the XRDPassedToEngine test
only validates that GetCompositeResourceDefinition() returns a non-nil value,
but does not verify that the actual XRD payload contains expected structure.
Enhance the assertion by adding a check for a stable field such as spec on the
returned XRD object to ensure the loaded XRD is properly forwarded to the
engine. This tightens the test and guarantees the XRD payload shape, not just
its presence.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6d4de0f5-81fd-4a70-b6d8-cb84f87ae6e8
⛔ Files ignored due to path filters (1)
cmd/crossplane/render/xr/testdata/cmd/xrd.yamlis excluded by!**/testdata/**and included by**/*.yaml
📒 Files selected for processing (2)
cmd/crossplane/render/xr/cmd.gocmd/crossplane/render/xr/cmd_test.go
Description of your changes
The XRD was loaded and used for applying defaults, but never passed to
CompositionInputs. The render engine comment explicitly says:For
LegacyClusterXRDs, this means resourceRefs end up atspec.crossplane.resourceRefsinstead ofspec.resourceRefs, which is incorrect and furtherly causing a validation error.Fixes #118
I have:
./nix.sh flake checkto ensure this PR is ready for review.[ ] Linked a PR or a docs tracking issue to document this change.[ ] Addedbackport release-x.ylabels to auto-backport this PR.Need help with this checklist? See the cheat sheet.