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.

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: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: 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)