{"record":{"id":"61b037b4d4ee9111","repo":"GitbookIO/gitbook","slug":"expected-schema-of-object-to-be-provided-schema","errorCode":null,"errorMessage":"Expected schema of object to be provided: ${schema.type}","messagePattern":"Expected schema of object to be provided: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/expr/src/input-values.ts","lineNumber":20,"sourceCode":"\nimport { filterOutNullable } from './utils';\n\ntype InputValuesType =\n    | null\n    | string\n    | number\n    | boolean\n    | { [key: string]: InputValuesType }\n    | InputValuesType[];\n\n/**\n * Infers a default inputValues object based on the JSON schema of an object.\n */\nexport function inferDefaultInputValuesFromObjectJSONSchema(\n    schema: JSONSchema7\n): Record<string, InputValuesType> {\n    if (schema.type !== 'object' || !schema.properties) {\n        throw new Error(`Expected schema of object to be provided: ${schema.type}`);\n    }\n\n    const result: Record<string, InputValuesType> = {};\n\n    for (const [key, propertySchema] of Object.entries(schema.properties)) {\n        if (typeof propertySchema === 'boolean') {\n            continue;\n        }\n\n        result[key] = inferDefaultInputValueFromJSONSchema(propertySchema);\n    }\n\n    return result;\n}\n\nfunction inferDefaultInputValueFromJSONSchema(schema: JSONSchema7): InputValuesType {\n    switch (schema.type) {\n        case 'object':","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/GitbookIO/gitbook/blob/db67585ee243d063c459a855988f21612cea9c95/packages/expr/src/input-values.ts#L2-L38","documentation":"Thrown by inferDefaultInputValuesFromObjectJSONSchema in @gitbook/expr when the passed JSON schema is not of type 'object' or has no properties map. The function only produces a Record<string, InputValuesType> from an object schema's properties, so arrays, strings, or object schemas without properties are rejected.","triggerScenarios":"Calling defaultInputValues or inferDefaultInputValuesFromObjectJSONSchema with a schema whose type is 'array', 'string', 'number', or an object schema missing/empty properties (undefined properties triggers it too).","commonSituations":"Feeding a JSON Schema that describes an array or scalar instead of an object; schemas generated from tooling that omit properties; passing a $ref that hasn't been dereferenced so type/properties are absent; version changes in @gitbook/expr tightening schema requirements.","solutions":["Check schema.type === 'object' and schema.properties exists before calling; use inferDefaultInputValueFromJSONSchema for non-object schemas","Dereference $refs first so the concrete type/properties are present","If the input really is an array/scalar, switch to the single-value inference API"],"exampleFix":"// before\nconst values = inferDefaultInputValuesFromObjectJSONSchema(arraySchema); // type: 'array'\n\n// after\nconst values =\n    schema.type === 'object'\n        ? inferDefaultInputValuesFromObjectJSONSchema(schema)\n        : { value: inferDefaultInputValueFromJSONSchema(schema) };","handlingStrategy":"type-guard","validationCode":"const isObjectSchema = (s: JSONSchema7) => s.type === 'object' && !!s.properties;","typeGuard":"function isObjectJSONSchema(schema: JSONSchema7): schema is JSONSchema7 & { type: 'object'; properties: Record<string, JSONSchema7Definition> } {\n    return schema.type === 'object' && typeof schema.properties === 'object' && schema.properties !== null;\n}","tryCatchPattern":null,"preventionTips":["Dereference $refs before inferring defaults","Route non-object schemas to inferDefaultInputValueFromJSONSchema","Validate generated schemas with a JSON Schema meta-validator first"],"tags":["json-schema","validation","expr","input-values"],"backgroundTag":"schema-validation-failed","analyzedSha":"db67585ee243d063c459a855988f21612cea9c95","analyzedAt":"2026-08-28T17:49:47.831Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}