{"record":{"id":"e1b3b6a41e78bc4a","repo":"octobercms/october","slug":"inspector-data-schema-must-be-an-array","errorCode":null,"errorMessage":"Inspector data schema must be an array","messagePattern":"Inspector data schema must be an array","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"modules/backend/vuecomponents/inspector/assets/js/classes/host.js","lineNumber":16,"sourceCode":"export class InspectorHost {\n    showModal(title, obj, dataSchema, uniqueId, options, parentObj) {\n        if (typeof title !== 'string' || !title.length) {\n            throw new Error('Inspector title is a required string');\n        }\n\n        if (typeof obj !== 'object') {\n            throw new Error('Inspector Object must be an object');\n        }\n\n        if (parentObj !== undefined && typeof parentObj !== 'object') {\n            throw new Error('Inspector Parent Object must be an object');\n        }\n\n        if (!Array.isArray(dataSchema)) {\n            throw new Error('Inspector data schema must be an array');\n        }\n\n        if (typeof uniqueId !== 'string' || !uniqueId.length) {\n            throw new Error('Inspector unique key is a required string');\n        }\n\n        if (options) {\n            if (typeof options !== 'object') {\n                throw new Error('options must be an object');\n            }\n\n            if (options.buttonText && typeof options.buttonText !== 'string') {\n                throw new Error('options.buttonText must be a string');\n            }\n\n            if (options.size && typeof options.size !== 'string') {\n                throw new Error('options.size must be a string');\n            }","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/vuecomponents/inspector/assets/js/classes/host.js#L1-L34","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Wrap single definitions in an array: [{ property: 'x', title: 'X' }].","JSON.parse schema strings before calling showModal.","Fetch and transform the schema before opening the modal rather than passing null."],"exampleFix":"// before\nhost.showModal(title, obj, { property: 'size', title: 'Size' }, uniqueId);\n\n// after\nhost.showModal(title, obj, [{ property: 'size', title: 'Size' }], uniqueId);","handlingStrategy":"validation","validationCode":"const schema = Array.isArray(rawSchema) ? rawSchema : JSON.parse(rawSchema);\nif (!Array.isArray(schema)) {\n    console.error('Inspector schema must resolve to an array');\n    return;\n}\nhost.showModal(title, obj, schema, uniqueId);","typeGuard":"function isInspectorSchema(value) {\n    return Array.isArray(value);\n}","tryCatchPattern":null,"preventionTips":["Wrap single property definitions in an array","Parse schema strings from AJAX responses before use"],"tags":["inspector","argument-validation","schema","modal","vue"],"backgroundTag":"invalid-argument-type","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}