{"record":{"id":"8660c600f7d8175c","repo":"openmediavault/openmediavault","slug":"no-items-attribute-defined","errorCode":null,"errorMessage":"{}: No 'items' attribute defined.","messagePattern":"(.+?): No 'items' attribute defined\\.","errorType":"exception","errorClass":"SchemaException","httpStatus":null,"severity":"error","filePath":"deb/openmediavault/usr/lib/python3/dist-packages/openmediavault/json/schema.py","lineNumber":525,"sourceCode":"                )\n            )\n        for propk, propv in schema['properties'].items():\n            # Build the new path. Strip empty parts.\n            parts = [name, propk]\n            parts = [part for part in parts if part]\n            path = \".\".join(parts)\n            # Check if the 'required' attribute is set.\n            if propk not in value:\n                if (\"required\" in propv) and (propv['required'] is True):\n                    raise SchemaValidationException(\n                        name, \"Missing 'required' attribute '%s'.\" % path\n                    )\n                continue\n            self._validate_type(value[propk], propv, path)\n\n    def _check_items(self, value, schema, name):\n        if \"items\" not in schema:\n            raise SchemaException(\n                \"{}: No 'items' attribute defined.\".format(name)\n            )\n        if isinstance(schema['items'], list):\n            for itemk, itemv in enumerate(value):\n                path = \"%s[%d]\" % (name, itemk)\n                valid = False\n                for item_schema in schema['items']:\n                    try:\n                        self._validate_type(itemv, item_schema, path)\n                        valid = True\n                        break\n                    except SchemaValidationException:\n                        pass\n                if not valid:\n                    types = map(lambda x: x['type'], schema['items'])\n                    raise SchemaValidationException(\n                        name,\n                        \"Invalid 'items' value, must be one of the \"","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/openmediavault/openmediavault/blob/dce610eb66f624c640d0eb7ce401ddd65b763520/deb/openmediavault/usr/lib/python3/dist-packages/openmediavault/json/schema.py#L507-L543","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add an \"items\" key to the array schema describing the element type, e.g. \"items\": {\"type\": \"string\"}","For tuple-style arrays, provide \"items\" as a list with one schema per position","If the array contents are truly unrestricted, use the most permissive dict schema this validator accepts rather than omitting \"items\"","Validate the schema offline against a sample payload before deploying the data model"],"exampleFix":"// before\n{\"type\": \"array\"}\n// after\n{\"type\": \"array\", \"items\": {\"type\": \"string\"}}","handlingStrategy":"validation","validationCode":"def schema_has_items_for_all_arrays(schema):\n    if isinstance(schema, dict):\n        if schema.get(\"type\") == \"array\" and \"items\" not in schema:\n            return False\n        return all(schema_has_items_for_all_arrays(v) for v in schema.values())\n    if isinstance(schema, list):\n        return all(schema_has_items_for_all_arrays(v) for v in schema)\n    return True\n\nassert schema_has_items_for_all_arrays(my_schema), \"array schema missing 'items'\"","typeGuard":null,"tryCatchPattern":"from openmediavault.json.schema import Schema, SchemaException\ntry:\n    Schema(schema).validate(data)\nexcept SchemaException as exc:\n    # schema definition bug, not a data problem\n    log.error(\"Bad schema definition: %s\", exc)\n    raise","preventionTips":["Always pair \"type\": \"array\" with an \"items\" definition","Lint schema JSON files in CI with a check that every array type has items","Test every data model schema with a sample payload before release"],"tags":["json-schema","python","schema-definition","openmediavault"],"backgroundTag":"schema-validation-failed","analyzedSha":"dce610eb66f624c640d0eb7ce401ddd65b763520","analyzedAt":"2026-09-15T09:48:09.960Z","contentChangedAt":"2026-09-15T09:48:09.960Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}