{"record":{"id":"adbf9d1201d61a86","repo":"GitbookIO/gitbook","slug":"unsupported-schema-type-schema-type","errorCode":null,"errorMessage":"Unsupported schema type: ${schema.type}","messagePattern":"Unsupported schema type: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/expr/src/input-values.ts","lineNumber":58,"sourceCode":"        case 'array': {\n            if (schema.items && Array.isArray(schema.items)) {\n                return schema.items.map((itemSchema) => {\n                    if (typeof itemSchema === 'boolean') {\n                        return false;\n                    }\n                    return inferDefaultInputValueFromJSONSchema(itemSchema);\n                });\n            }\n            return [];\n        }\n        case 'string':\n        case 'number':\n        case 'integer':\n        case 'boolean':\n        case 'null':\n            return inferDefaultInputValueFromPrimitive(schema);\n        default:\n            throw new Error(`Unsupported schema type: ${schema.type}`);\n    }\n}\n\nfunction inferDefaultInputValueFromPrimitive(schema: JSONSchema7): InputValuesType {\n    switch (schema.type) {\n        case 'boolean':\n            return true;\n        case 'number':\n        case 'integer':\n            return 1234;\n        case 'string': {\n            const enumValues = schema.enum?.filter(filterOutNullable);\n            return enumValues?.[0] ?? 'default';\n        }\n        case 'null':\n            return null;\n        default:\n            throw new Error(`Unsupported schema type: ${schema.type}`);","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/GitbookIO/gitbook/blob/db67585ee243d063c459a855988f21612cea9c95/packages/expr/src/input-values.ts#L40-L76","documentation":"Thrown by inferDefaultInputValueFromJSONSchema in @gitbook/expr when the schema type falls into the switch's default branch. Only string, number, integer, boolean, null, array, and object are handled; any other (or missing/invalid) type value such as undefined is rejected.","triggerScenarios":"Passing a schema whose type is undefined (e.g. a schema using oneOf/anyOf without a top-level type), a typo'd type, or a type added by newer JSON Schema drafts that this version doesn't know.","commonSituations":"Schemas with combinators (oneOf/anyOf/allOf) at the root instead of a concrete type; hand-built schema objects missing the type field; version mismatches between the JSON Schema producer and @gitbook/expr's supported types.","solutions":["Ensure every schema passed has a concrete, supported type (string|number|integer|boolean|null|array|object)","Normalize combinator schemas by resolving oneOf/anyOf to one concrete branch before inference","Add a default branch returning a sensible fallback instead of relying on the library throwing"],"exampleFix":"// before\nconst value = inferDefaultInputValueFromJSONSchema({ oneOf: [] }); // no type\n\n// after\nconst value = inferDefaultInputValueFromJSONSchema({ type: 'string' });","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = new Set(['string','number','integer','boolean','null','array','object']);\nif (!SUPPORTED.has(schema.type ?? '')) {\n    // normalize schema (resolve oneOf/anyOf) before inference\n}","typeGuard":"function hasSupportedSchemaType(schema: JSONSchema7): boolean {\n    return ['string','number','integer','boolean','null','array','object'].includes(schema.type as string);\n}","tryCatchPattern":null,"preventionTips":["Resolve oneOf/anyOf combinators to a concrete branch before inference","Always set an explicit type when authoring schemas"],"tags":["json-schema","validation","expr","switch-default"],"backgroundTag":"schema-validation-failed","analyzedSha":"db67585ee243d063c459a855988f21612cea9c95","analyzedAt":"2026-08-28T17:49:47.831Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}