openmediavault/openmediavault · error · SchemaException

: No 'items' attribute defined.

Error message

{}: No 'items' attribute defined.

What it means

The openmediavault JSON schema validator requires every schema of type "array" to carry an "items" keyword describing the permitted structure of the array's elements. When _check_items (invoked from _validate_array during Schema.validate()) finds an array-typed schema without "items", it raises this SchemaException. Unlike a data validation error, this signals a malformed schema definition.

Solutions

  1. Add an "items" key to the array schema describing the element type, e.g. "items": {"type": "string"}
  2. For tuple-style arrays, provide "items" as a list with one schema per position
  3. If the array contents are truly unrestricted, use the most permissive dict schema this validator accepts rather than omitting "items"
  4. Validate the schema offline against a sample payload before deploying the data model

Example fix

// before
{"type": "array"}
// after
{"type": "array", "items": {"type": "string"}}
Defensive patterns

Strategy: validation

Validate before calling

def schema_has_items_for_all_arrays(schema):
    if isinstance(schema, dict):
        if schema.get("type") == "array" and "items" not in schema:
            return False
        return all(schema_has_items_for_all_arrays(v) for v in schema.values())
    if isinstance(schema, list):
        return all(schema_has_items_for_all_arrays(v) for v in schema)
    return True

assert schema_has_items_for_all_arrays(my_schema), "array schema missing 'items'"

Try / catch

from openmediavault.json.schema import Schema, SchemaException
try:
    Schema(schema).validate(data)
except SchemaException as exc:
    # schema definition bug, not a data problem
    log.error("Bad schema definition: %s", exc)
    raise

Prevention

When it happens

Trigger: Calling openmediavault.json.schema.Schema(schema).validate(data) where the schema contains {"type": "array"} without an "items" key — including nested arrays inside object properties or array-of-arrays where the inner array schema omits "items". The check runs unconditionally for array types, before any element is examined.

Common situations: Hand-written OMV datamodel or RPC parameter schema files that define "type": "array" but forget the element definition; schemas migrated from generic JSON Schema drafts where "items" was optional; hand-edited config schemas where an "items" block was accidentally deleted during a merge.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of openmediavault/openmediavault@dce610eb66 (2026-09-15). Data as JSON: /api/errors/8660c600f7d8175c. Report an issue: GitHub.

Appendix: source

Thrown at deb/openmediavault/usr/lib/python3/dist-packages/openmediavault/json/schema.py:525

                )
            )
        for propk, propv in schema['properties'].items():
            # Build the new path. Strip empty parts.
            parts = [name, propk]
            parts = [part for part in parts if part]
            path = ".".join(parts)
            # Check if the 'required' attribute is set.
            if propk not in value:
                if ("required" in propv) and (propv['required'] is True):
                    raise SchemaValidationException(
                        name, "Missing 'required' attribute '%s'." % path
                    )
                continue
            self._validate_type(value[propk], propv, path)

    def _check_items(self, value, schema, name):
        if "items" not in schema:
            raise SchemaException(
                "{}: No 'items' attribute defined.".format(name)
            )
        if isinstance(schema['items'], list):
            for itemk, itemv in enumerate(value):
                path = "%s[%d]" % (name, itemk)
                valid = False
                for item_schema in schema['items']:
                    try:
                        self._validate_type(itemv, item_schema, path)
                        valid = True
                        break
                    except SchemaValidationException:
                        pass
                if not valid:
                    types = map(lambda x: x['type'], schema['items'])
                    raise SchemaValidationException(
                        name,
                        "Invalid 'items' value, must be one of the "

View on GitHub (pinned to dce610eb66)