octobercms/october · error · Error

Inspector data schema must be an array

Error message

Inspector data schema must be an array

What it means

The `dataSchema` argument of showModal() must be an array of property-definition objects — even a single-property inspector wraps its definition in an array. Passing an object literal, a JSON string, or null throws immediately, because the modal builds its editor list by iterating the schema.

Source

Thrown at modules/backend/vuecomponents/inspector/assets/js/classes/host.js:16

export class InspectorHost {
    showModal(title, obj, dataSchema, uniqueId, options, parentObj) {
        if (typeof title !== 'string' || !title.length) {
            throw new Error('Inspector title is a required string');
        }

        if (typeof obj !== 'object') {
            throw new Error('Inspector Object must be an object');
        }

        if (parentObj !== undefined && typeof parentObj !== 'object') {
            throw new Error('Inspector Parent Object must be an object');
        }

        if (!Array.isArray(dataSchema)) {
            throw new Error('Inspector data schema must be an array');
        }

        if (typeof uniqueId !== 'string' || !uniqueId.length) {
            throw new Error('Inspector unique key is a required string');
        }

        if (options) {
            if (typeof options !== 'object') {
                throw new Error('options must be an object');
            }

            if (options.buttonText && typeof options.buttonText !== 'string') {
                throw new Error('options.buttonText must be a string');
            }

            if (options.size && typeof options.size !== 'string') {
                throw new Error('options.size must be a string');
            }

View on GitHub (pinned to b608633a7e)

Solutions

  1. Wrap single definitions in an array: [{ property: 'x', title: 'X' }].
  2. JSON.parse schema strings before calling showModal.
  3. Fetch and transform the schema before opening the modal rather than passing null.

Example fix

// before
host.showModal(title, obj, { property: 'size', title: 'Size' }, uniqueId);

// after
host.showModal(title, obj, [{ property: 'size', title: 'Size' }], uniqueId);
Defensive patterns

Strategy: validation

Validate before calling

const schema = Array.isArray(rawSchema) ? rawSchema : JSON.parse(rawSchema);
if (!Array.isArray(schema)) {
    console.error('Inspector schema must resolve to an array');
    return;
}
host.showModal(title, obj, schema, uniqueId);

Type guard

function isInspectorSchema(value) {
    return Array.isArray(value);
}

Prevention

When it happens

Trigger: showModal(title, obj, { property: 'x', title: 'X' }, id) — a single object instead of [{...}]; passing a schema string from an AJAX response without JSON.parse; passing null with the intent to load the schema later.

Common situations: Hand-writing the first schema for a custom inspector; schemas fetched from an endpoint that returns a string; refactoring between YAML field configs and JS schema arrays.

Understand the failure class

Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.

Related errors


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/e1b3b6a41e78bc4a. Report an issue: GitHub.