When loading a schema through the API, the default_value field is not validated, and the new model is created.
If an invalid value is set as default_value, the API returns an error when we try to create a new object using a schema with an incompatible default value.
Expected Behavior
When loading a schema through the API, the default_value field is not validated, the model schould not be created and the API should returns an error specifying why it fails (ideally listing all wrong default_value)
Steps to Reproduce
load the following schema:
{
"schemas": [
{
"version": "1.0",
"nodes": [
{
"name": "Allinonetest",
"namespace": "Test",
"description": "object with all attributes with default value",
"label": "All in one test number",
"icon": "mdi:server",
"default_filter": "text__value",
"inherit_from": ["InfraEndpoint"],
"order_by": [
"text__value"
],
"display_labels": [
"text__value"
],
"attributes": [
{
"name": "idd",
"kind": "ID",
"optional": true,
"unique": true,
"default_value": 0,
"description": "id input for testing and development"
},
{
"name": "text",
"kind": "Text",
"unique": true,
"optional": true,
"unique": true,
"default_value": 0,
"description": "text input for testing and development"
},
{
"name": "primary",
"kind": "Number",
"optional": false,
"default_value": 0
},
{
"name": "secondary",
"kind": "Number",
"optional": true,
"default_value": -23
},
{
"name": "enum",
"label": "Role",
"kind": "Text",
"unique": false,
"optional": true,
"unique": false,
"enum": [
"admin",
"read-only",
"read-write"
],
"description": "id input for testing and development"
},
{
"name": "enum_with_default",
"label": "Enum with default",
"kind": "Text",
"unique": false,
"optional": true,
"unique": false,
"enum": [
"User",
"Script",
"Bot",
"Git"
],
"default_value": "User",
"description": "enum with default input for testing and development"
},
{
"name": "textarea",
"kind": "TextArea",
"optional": true,
"unique": false,
"default_value": 0,
"description": "textarea input for testing and development"
},
{
"name": "datetime",
"kind": "DateTime",
"optional": true,
"unique": false,
"default_value": 0,
"description": "datetime input for testing and development"
},
{
"name": "password",
"kind": "Password",
"optional": true,
"unique": false,
"default_value": 0,
"description": "password input for testing and development"
},
{
"name": "email",
"kind": "Email",
"optional": true,
"unique": false,
"default_value": 0,
"description": "email input for testing and development"
},
{
"name": "hashedpassword",
"kind": "HashedPassword",
"optional": true,
"unique": false,
"default_value": 0,
"description": "hashed password input for testing and development"
},
{
"name": "url",
"kind": "URL",
"optional": true,
"unique": false,
"default_value": 0,
"description": "{% request 'url', '', 0 %} input for testing and development"
},
{
"name": "file",
"kind": "File",
"optional": true,
"unique": false,
"default_value": 0,
"description": "file input for testing and development"
},
{
"name": "macaddress",
"kind": "MacAddress",
"optional": true,
"unique": false,
"default_value": 0,
"description": "macaddress input for testing and development"
},
{
"name": "color",
"kind": "Color",
"optional": true,
"default_value": 0,
"unique": false,
"description": "color input for testing and development"
},
{
"name": "bandwidth",
"kind": "Bandwidth",
"optional": true,
"default_value": 0,
"unique": false,
"description": "bandwith input for testing and development"
},
{
"name": "iphost",
"kind": "IPHost",
"optional": true,
"default_value": 0,
"unique": false,
"description": "iphost input for testing and development"
},
{
"name": "ipnetwork",
"kind": "IPNetwork",
"optional": true,
"unique": false,
"default_value": 0,
"description": "ipnetwork input for testing and development"
},
{
"name": "checkbox",
"kind": "Checkbox",
"optional": true,
"unique": false,
"default_value": 0,
"description": "checkbox input for testing and development"
},
{
"name": "list",
"kind": "List",
"optional": true,
"unique": false,
"default_value": 0,
"description": "list input for testing and development"
},
{
"name": "anyy",
"kind": "Any",
"optional": true,
"unique": false,
"default_value": 0,
"description": "any input for testing and development"
},
{
"name": "boolean",
"kind": "Boolean",
"optional": true,
"unique": false,
"default_value": false,
"description": "boolean input for testing and development"
},
{
"name": "json",
"kind": "JSON",
"optional": true,
"unique": false,
"default_value": 0,
"description": "json input for testing and development"
},
{
"name": "dropdown",
"kind": "Dropdown",
"optional": true,
"unique": false,
"default_value": 0,
"choices": [
{
"name": "active",
"label": "Active",
"description": "Fully operational and currently in service",
"color": "#7fbf7f"
},
{
"name": "provisioning",
"label": "Provisioning",
"description": "In the process of being set up and configured",
"color": "#ffff7f"
},
{
"name": "maintenance",
"label": "Maintenance",
"description": "Undergoing routine maintenance or repairs",
"color": "#ffd27f"
},
{
"name": "drained",
"label": "Drained",
"description": "Temporarily taken out of service",
"color": "#bfbfbf"
}
],
"description": "dropdown input for testing and development"
}
],
"relationships": [
{
"name": "tagone",
"peer": "BuiltinTag",
"optional": true,
"cardinality": "many",
"kind": "Attribute",
"description": "relationship many input for testing and development"
},
{
"name": "country",
"peer": "LocationCountry",
"optional": true,
"cardinality": "one",
"kind": "Generic",
"description": "relationship one input for testing and development"
}
]
}
]
}
]
}
Try to create an object without touching fields with a default value on frontend.
Component
API Server / GraphQL
Current Behavior
When loading a schema through the API, the
default_value field
is not validated, and the new model is created.If an invalid value is set as
default_value
, the API returns an error when we try to create a new object using a schema with an incompatible default value.Expected Behavior
When loading a schema through the API, the
default_value field
is not validated, the model schould not be created and the API should returns an error specifying why it fails (ideally listing all wrong default_value)Steps to Reproduce
Additional Information
No response