{"record":{"id":"ca90c69cc32cac6e","repo":"BoundaryML/baml","slug":"property-name-not-found","errorCode":null,"errorMessage":"Property ${name} not found.","messagePattern":"Property (.+?) not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"engine/language_client_typescript/type_builder.js","lineNumber":116,"sourceCode":"    }\n    listProperties() {\n        return this.bldr.listProperties();\n    }\n    type() {\n        return this.bldr.field();\n    }\n}\nexports.ClassAst = ClassAst;\nclass ClassViewer extends ClassAst {\n    constructor(tb, name, properties = new Set()) {\n        super(tb, name, properties);\n    }\n    listProperties() {\n        return Array.from(this.properties).map((name) => [name, new ClassPropertyViewer()]);\n    }\n    property(name) {\n        if (!this.properties.has(name)) {\n            throw new Error(`Property ${name} not found.`);\n        }\n        return new ClassPropertyViewer();\n    }\n}\nexports.ClassViewer = ClassViewer;\nclass ClassBuilder extends ClassAst {\n    constructor(tb, name, properties = new Set()) {\n        super(tb, name, properties);\n    }\n    addProperty(name, type) {\n        if (this.properties.has(name)) {\n            throw new Error(`Property ${name} already exists.`);\n        }\n        this.properties.add(name);\n        return new ClassPropertyBuilder(this.bldr.property(name).setType(type));\n    }\n    listProperties() {\n        return this.bldr.listProperties().map(([name, prop]) => [name, new ClassPropertyBuilder(prop)]);","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_typescript/type_builder.js#L98-L134","documentation":"ClassViewer.property(name) throws when the requested property does not exist on the viewed class definition. The JS viewer keeps a Set of known property names and validates membership before returning a ClassPropertyViewer, since there is no underlying object to return otherwise.","triggerScenarios":"Calling viewer.property(\"x\") for a property never added via addProperty; typo in the property name; querying a property added to a different ClassBuilder/Viewer instance.","commonSituations":"Refactors that renamed a class field without updating viewer lookups; introspection code driven by external config/JSON referencing stale field names; case-sensitivity mistakes (e.g. 'UserId' vs 'userId').","solutions":["Call listProperties() first and confirm the exact property name before property()","Fix the property-name typo/casing","Ensure you add the property (addProperty) before attempting to view it","Verify you are calling property() on the same ClassBuilder/Viewer that owns the property"],"exampleFix":"// before\nconst p = viewer.property(\"userName\"); // throws, actual name is \"username\"\n// after\nconst names = viewer.listProperties().map(([n]) => n);\nif (names.includes(\"username\")) {\n  const p = viewer.property(\"username\");\n}","handlingStrategy":"validation","validationCode":"const available = viewer.listProperties().map(([n]) => n);\nif (!available.includes(name)) throw new Error(`property '${name}' not in [${available}]`);","typeGuard":"null","tryCatchPattern":"try { viewer.property(name); } catch (e) {\n  if (String(e.message).includes('not found')) { /* handle missing property */ }\n  else throw e;\n}","preventionTips":["List properties before looking one up","Keep property names in sync with schema/config sources","Watch for casing differences in property names"],"tags":["javascript","type-builder","property","lookup","baml"],"backgroundTag":"entity-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"}