{"record":{"id":"0180fe0d4cfb1e8a","repo":"can1357/oh-my-pi","slug":"mapped-property-string-property-key-has-invali","errorCode":null,"errorMessage":"mapped property ${String(property.key)} has invalid kind","messagePattern":"mapped property (.+?) has invalid kind","errorType":"exception","errorClass":"OmpTypeError","httpStatus":null,"severity":"error","filePath":"packages/omptype/src/type.ts","lineNumber":1757,"sourceCode":"}\n\nfunction mergeObjectDefinition(ir: IR, definition: unknown, resolve?: AliasResolver): ObjectIR {\n\treturn mergeObjects(requireObject(ir, \"merge\"), requireObject(parseDef(definition, resolve), \"merge\"));\n}\n\nfunction propertyFromIR(prop: PropIR): TypeProperty {\n\treturn {\n\t\tkind: prop.opt ? \"optional\" : \"required\",\n\t\tkey: prop.key,\n\t\tvalue: makeType(prop.val, [], {}) as unknown as FluentType<unknown>,\n\t\t...(prop.hasDefault ? { default: prop.def } : {}),\n\t\tmeta: {},\n\t};\n}\n\nfunction propertyToIR(property: TypeProperty): PropIR {\n\tif (property.kind !== \"required\" && property.kind !== \"optional\") {\n\t\tthrow new OmpTypeError(`mapped property ${String(property.key)} has invalid kind`);\n\t}\n\tif (!(IR_BRAND in property.value)) {\n\t\tthrow new OmpTypeError(`mapped property ${String(property.key)} must contain a schema value`);\n\t}\n\tconst hasDefault = Object.hasOwn(property, \"default\");\n\treturn {\n\t\tkey: property.key,\n\t\topt: property.kind === \"optional\",\n\t\tval: embed(property.value),\n\t\t...(hasDefault\n\t\t\t? { def: property.default, defFactory: typeof property.default === \"function\", hasDefault: true }\n\t\t\t: {}),\n\t};\n}\n\nfunction acceptsDateIR(ir: IR): boolean {\n\tif (ir.k === \"instance\") return ir.ctor === Date;\n\tif (ir.k === \"refine\") return acceptsDateIR(ir.base);","sourceCodeStart":1739,"sourceCodeEnd":1775,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/omptype/src/type.ts#L1739-L1775","documentation":"omptype throws this while converting an object property to its internal IR representation. Every TypeProperty must have kind 'required' or 'optional'; anything else means the property object was malformed or constructed outside the library's public builders. The library refuses to compile an object schema with an unknown property kind rather than silently guessing optionality.","triggerScenarios":"Calling a builder (e.g. type({...})) with a property whose kind field was hand-crafted or corrupted, or passing a mapped/computed property object that skipped the required/optional normalization step.","commonSituations":"Hand-writing TypeProperty objects instead of using helpers like required()/optional(); upgrading omptype and relying on a removed internal kind value; a custom mapper producing properties without setting kind.","solutions":["Build properties with the library's required()/optional() helpers instead of literal objects","Log String(property.key) from the message to find the offending key and inspect its kind value","Check for version drift: internal kinds are not public API; regenerate any code that constructs TypeProperty directly","Assert kind at your boundary before passing a property into type()"],"exampleFix":"// before\ntype({ name: { key: 'name', kind: 'maybe', value: string } })\n// after\ntype({ name: optional(string) })","handlingStrategy":"validation","validationCode":"function isValidProperty(p) {\n  return p && (p.kind === 'required' || p.kind === 'optional') && p.value && String(p.key).length > 0;\n}\n// call before type({...}): Object.values(props).every(isValidProperty)","typeGuard":"function isTypeProperty(p): p is TypeProperty {\n  return typeof p === 'object' && p !== null && (p.kind === 'required' || p.kind === 'optional') && IR_BRAND in p.value;\n}","tryCatchPattern":"try {\n  const T = type(props);\n} catch (err) {\n  if (err instanceof OmpTypeError && err.message.includes('invalid kind')) {\n    throw new Error(`bad property definition: ${err.message}`);\n  }\n  throw err;\n}","preventionTips":["Always create properties via required()/optional() helpers","Treat TypeProperty internals as non-public API","Validate schema definitions loaded from JSON/config before compiling"],"tags":["omptype","schema","object-property","invalid-kind"],"backgroundTag":"invalid-schema-property-kind","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}