{"record":{"id":"137196cc349d78b2","repo":"can1357/oh-my-pi","slug":"type-operation-requires-a-schema-created-by-typ","errorCode":null,"errorMessage":"Type.${operation} requires a schema created by Type.Object","messagePattern":"Type\\.(.+?) requires a schema created by Type\\.Object","errorType":"exception","errorClass":"OmpTypeError","httpStatus":null,"severity":"error","filePath":"packages/omptype/src/typebox.ts","lineNumber":458,"sourceCode":"\treturn applyMeta(base, opts) as TRecord<K, V>;\n}\n\nfunction tOptional<E extends AnySchema>(schema: E, opts?: Meta): TOptional<E> {\n\tconst marker = applyMeta(\n\t\tasRuntime<Static<E>>(schema).or(asRuntime<undefined>(type.raw(\"undefined\"))),\n\t\topts,\n\t) as RuntimeType<Static<E> | undefined>;\n\tmarker[OPTIONAL_INNER] = schema;\n\treturn marker as unknown as TOptional<E>;\n}\n\nfunction tNullable<E extends AnySchema>(schema: E, opts?: Meta): TTyped<Static<E> | null> {\n\treturn applyMeta(asRuntime<Static<E>>(schema).or(asRuntime<null>(type.raw(\"null\"))), opts);\n}\n\nfunction requireObject(schema: AnySchema, operation: string): ObjectInfo {\n\tconst info = asRuntime<unknown>(schema)[OBJECT_INFO];\n\tif (!info) throw new OmpTypeError(`Type.${operation} requires a schema created by Type.Object`);\n\treturn info;\n}\n\nfunction tPartial<P extends Record<string, AnySchema>>(schema: TObject<P>): TTyped<Partial<ObjectStatic<P>>> {\n\tconst info = requireObject(schema, \"Partial\");\n\tconst props: Record<string, AnySchema> = {};\n\tfor (const key in info.props)\n\t\tprops[key] = asRuntime<unknown>(info.props[key])[OPTIONAL_INNER] ? info.props[key] : tOptional(info.props[key]);\n\treturn tObject(props, { additionalProperties: info.additionalProperties }) as TTyped<Partial<ObjectStatic<P>>>;\n}\n\nfunction tRequired<P extends Record<string, AnySchema>>(schema: TObject<P>): TObject<RequiredProps<P>> {\n\tconst info = requireObject(schema, \"Required\");\n\tconst props: Record<string, AnySchema> = {};\n\tfor (const key in info.props) {\n\t\tprops[key] = asRuntime<unknown>(info.props[key])[OPTIONAL_INNER] ?? info.props[key];\n\t}\n\treturn tObject(props, { additionalProperties: info.additionalProperties }) as TObject<RequiredProps<P>>;","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/omptype/src/typebox.ts#L440-L476","documentation":"Object-only combinators (`Type.Partial`, `Type.Required`, `Type.Omit`, `Type.Pick`, etc.) look up an internal OBJECT_INFO marker installed by `Type.Object`. `requireObject` throws `Type.<operation> requires a schema created by Type.Object` when the schema passed in lacks that marker, meaning it was built by any other constructor (tString, tArray, unions, or a plain TypeBox/zod schema).","triggerScenarios":"`Type.Partial(tString())`, applying `Type.Omit` to a union or array schema, or passing a schema from a foreign schema library (raw typebox/zod object) that omptype's `Type.Object` never tagged.","commonSituations":"Refactoring a field type from an object to an array/string without updating the downstream Partial/Pick call; mixing omptype `Type.*` helpers with schemas produced by other builders; passing `TObject` from plain typebox instead of omptype's `Type.Object`.","solutions":["Ensure the schema argument was created with omptype's `Type.Object({...})`, not another constructor or library.","Check the call site after field-type refactors: if the property is no longer an object, drop or replace the Partial/Pick/Required call.","If working with a raw typebox TObject, rebuild it through omptype's Type.Object so OBJECT_INFO gets attached."],"exampleFix":"// before\nconst partial = Type.Partial(tArray(tString()));\n// after\nconst config = Type.Object({ id: tString(), tags: tArray(tString()) });\nconst partial = Type.Partial(config);","handlingStrategy":"type-guard","validationCode":"// pass only Type.Object results into object combinators\nconst config = Type.Object({ id: tString(), tags: tArray(tString()) });\nconst partial = Type.Partial(config);","typeGuard":"function isOmpObjectSchema(s: unknown): s is TObject<Record<string, AnySchema>> {\n  return typeof s === 'object' && s !== null && (s as Record<symbol, unknown>)[OBJECT_INFO] !== undefined;\n}","tryCatchPattern":"try {\n  const partial = Type.Partial(maybeObject);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('requires a schema created by Type.Object')) {\n    throw new Error(`Partial/Omit/Pick need Type.Object input; got a non-object schema`);\n  }\n  throw err;\n}","preventionTips":["Keep field types stable, or grep call sites of Partial/Required/Omit/Pick when changing a field's shape.","Never mix schemas from plain typebox/zod into omptype Type.* object combinators.","Type the helper function parameters as TObject<...> so the compiler rejects non-object schemas."],"tags":["omptype","typebox","object-schema","schema-construction"],"backgroundTag":"schema-type-mismatch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}