{"record":{"id":"bdf5ac37752a9b10","repo":"BoundaryML/baml","slug":"property-name-not-found-type-builder","errorCode":null,"errorMessage":"Property ${name} not found.","messagePattern":"Property (.+?) not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"engine/language_client_typescript/typescript_src/type_builder.ts","lineNumber":169,"sourceCode":"    return this.bldr.field()\n  }\n}\n\nexport class ClassViewer<ClassName extends string, Properties extends string = string> extends ClassAst<\n  ClassName,\n  Properties\n> {\n  constructor(tb: _TypeBuilder, name: ClassName, properties: Set<Properties | string> = new Set()) {\n    super(tb, name, properties)\n  }\n\n  listProperties(): Array<[string, ClassPropertyViewer]> {\n    return Array.from(this.properties).map((name) => [name, new ClassPropertyViewer()])\n  }\n\n  property(name: string): ClassPropertyViewer {\n    if (!this.properties.has(name)) {\n      throw new Error(`Property ${name} not found.`)\n    }\n    return new ClassPropertyViewer()\n  }\n}\n\nexport class ClassBuilder<ClassName extends string, Properties extends string = string> extends ClassAst<\n  ClassName,\n  Properties\n> {\n  constructor(tb: _TypeBuilder, name: ClassName, properties: Set<Properties | string> = new Set()) {\n    super(tb, name, properties)\n  }\n\n  addProperty<S extends string>(name: RestrictNot<ClassName, S, Properties>, type: FieldType): ClassPropertyBuilder {\n    if (this.properties.has(name)) {\n      throw new Error(`Property ${name} already exists.`)\n    }\n    this.properties.add(name)","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_typescript/typescript_src/type_builder.ts#L151-L187","documentation":"ClassAst.property (viewer API) throws 'Property <name> not found.' when the requested property name is not among the properties registered for the class being viewed. The viewer keeps a Set of property names and rejects unknown lookups instead of returning null. It is a read-path companion to the addProperty duplicate check.","triggerScenarios":"Calling clsViewer.property('foo') where 'foo' was never added via addProperty on the builder, or after a typo / case mismatch in the property name.","commonSituations":"Inspecting a dynamically built class whose properties depend on runtime data; accessing a property renamed in a schema update.","solutions":["Call listProperties() first and confirm the exact property name before lookup.","Fix the property name spelling/casing in the lookup call.","Add the missing property via the ClassBuilder's addProperty before inspecting it."],"exampleFix":"// before\nconst p = viewer.property('userName') // throws if absent\n// after\nconst names = viewer.listProperties().map(([n]) => n)\nif (names.includes('userName')) { const p = viewer.property('userName') }","handlingStrategy":"validation","validationCode":"const exists = viewer.listProperties().some(([n]) => n === name)\nif (!exists) throw new Error(`property '${name}' missing before lookup`)","typeGuard":null,"tryCatchPattern":"try {\n  const p = viewer.property(name)\n} catch (e) {\n  if (e.message.includes('not found')) return null\n  throw e\n}","preventionTips":["Always call listProperties() before dynamic lookups.","Derive property names from schema constants, not hand-typed strings.","Ensure addProperty ran for every property you later inspect."],"tags":["typescript","schema","type-builder","lookup"],"backgroundTag":"resource-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}