fix(types): omit XValidation for required fields with references - #684
Conversation
When a field is marked as required but also has a reference configured, the field becomes satisfiable via *Ref/*Selector mechanisms. Explicitly set f.Required=false in NewReferenceField so no XValidation rule is emitted for such fields. Signed-off-by: Jonasz Łasut-Balcerzak <jonasz@upbound.io>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughReferenced fields now clear their required state, and the build test adds a regression case confirming that a required referenced field does not emit XValidation. ChangesReference field required handling
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 7✅ Passed checks (7 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 |
ulucinar
left a comment
There was a problem hiding this comment.
Thank you @jonasz-lasut, lgtm.
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin release-1.11
git worktree add -d .worktree/backport-684-to-release-1.11 origin/release-1.11
cd .worktree/backport-684-to-release-1.11
git switch --create backport-684-to-release-1.11
git cherry-pick -x 3b9b01c64126c413d156c8867a2b0da399a5064b |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin release-1.10
git worktree add -d .worktree/backport-684-to-release-1.10 origin/release-1.10
cd .worktree/backport-684-to-release-1.10
git switch --create backport-684-to-release-1.10
git cherry-pick -x 3b9b01c64126c413d156c8867a2b0da399a5064b |
Description of your changes
When a field is marked as required but also has a reference configured, the field becomes satisfiable via *Ref/*Selector mechanisms. Explicitly set f.Required=false in NewReferenceField so no XValidation rule is emitted for such fields.
Fixes issue observed in crossplane-contrib/provider-upjet-gcp#952
I have:
make reviewableto ensure this PR is ready for review.- [ ] Addedbackport release-x.ylabels to auto-backport this PR if necessary.How has this code been tested
Added unit test that validates this behavior