octobercms/october · error · Error

Inspector Object must be an object

Error message

Inspector Object must be an object

What it means

The second showModal() check requires the inspected value itself (`obj`) to be a JavaScript object — the inspector binds its property editors to it. Passing null, a primitive, or a JSON string throws before the modal opens, because there is nothing to bind the schema to.

Source

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

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');
            }

View on GitHub (pinned to b608633a7e)

Solutions

  1. Pass the plain object being inspected.
  2. JSON.parse serialized payloads before handing them to showModal.
  3. Only open the modal once the object is actually loaded (guard async flows).

Example fix

// before
host.showModal(title, this.fetchedRecord, schema, uniqueId); // may be undefined

// after
if (!this.fetchedRecord) {
    return;
}
host.showModal(title, this.fetchedRecord, schema, uniqueId);
Defensive patterns

Strategy: validation

Validate before calling

const modalObj = typeof obj === 'object' && obj !== null ? obj : null;
if (!modalObj) {
    console.error('Inspector modal requires a loaded object');
    return;
}
host.showModal(title, modalObj, schema, uniqueId);

Type guard

function isInspectorObject(value) {
    return typeof value === 'object' && value !== null;
}

Prevention

When it happens

Trigger: showModal(title, null, schema, id); passing a JSON.stringify'd object instead of the parsed one; passing a record id or other scalar where the record object was intended; opening the modal before an async fetch resolves (obj still undefined).

Common situations: Async data flows where the modal opens on click but the object is still loading; legacy code holding records as serialized strings; argument-order mistakes after adding the options parameter.

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/6066b23677ababa6. Report an issue: GitHub.