Crossplane XRD Schema Validation Rejected
In this tutorial, you'll learn about Crossplane XRD Schema Validation Rejected. We cover key concepts, practical examples, and best practices.
A CompositeResourceDefinition (XRD) update is rejected or doesn't validate input fields correctly.
Wrong ❌
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xdatabases.example.org
spec:
group: example.org
names:
kind: XMyDatabase
plural: xmydatabases
versions:
- name: v1alpha1
served: true
referenceable: true
# Missing schema block
Wrong Output
Error from server (BadRequest): error when creating XRD:
spec.versions[0].schema.openAPIV3Schema.properties.spec.properties: Required value
The XRD schema must be defined for each version
Right ✅
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xdatabases.example.org
spec:
group: example.org
names:
kind: XMyDatabase
plural: xmydatabases
claimNames:
kind: MyDatabase
plural: mydatabases
versions:
- name: v1alpha1
served: true
referenceable: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
parameters:
type: object
properties:
region:
type: string
enum: [us-east-1, eu-west-1]
version:
type: string
required: [region]
Right Output
compositeresourcedefinition.apiextensions.crossplane.io/xdatabases.example.org created
XRD is ready: Established condition is True
Prevention
- Always define the openAPIV3Schema for each XRD version with proper type definitions.
- Use enum constraints for fields with known valid values (e.g., regions, instance types).
- Mark required fields with the required array at the appropriate nesting level.
- Define claimNames only if you want users to create Claims that compose into this XRD.
- Test XRD validation: try creating an XR with missing required fields to confirm validation works.
DodaTech applies similar defensive patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro infrastructure for production reliability.
Common Mistakes with xrd schema
- Using
returnto exit a function early instead of wrapping a pure value in the monad - Mixing let bindings with <- bindings in do notation, producing type errors
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
These mistakes appear frequently in real-world CROSSPLANE code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
This quick fix is part of the DodaTech infrastructure engineering series. Learn more at DodaTech tutorials.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro