{"record":{"id":"23b2effefae793f3","repo":"BoundaryML/baml","slug":"class-0-not-found","errorCode":null,"errorMessage":"Class '{0}' not found","messagePattern":"Class '(.+?)' not found","errorType":"exception","errorClass":"RenderError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/sys_ops/src/output_format.rs","lineNumber":13,"sourceCode":"use std::fmt::Write as _;\n\nuse ::sys_types::SapTy;\nuse baml_base::Literal as LiteralValue;\nuse indexmap::IndexMap;\nuse thiserror::Error;\n\n/// Error type for output format rendering.\n#[derive(Clone, Debug, Error)]\npub enum RenderError {\n    #[error(\"Enum '{0}' not found\")]\n    EnumNotFound(String),\n    #[error(\"Class '{0}' not found\")]\n    ClassNotFound(String),\n    #[error(\"Type '{0}' is not supported in outputs\")]\n    UnsupportedType(String),\n    #[error(\n        \"Non-regular recursive generic class '{class}' expands from '{ancestor}' to '{instantiation}'\"\n    )]\n    NonRegularRecursiveGeneric {\n        class: String,\n        ancestor: String,\n        instantiation: String,\n    },\n    #[error(\n        \"Output definitions '{first}' and '{second}' both render as '{rendered_name}' in the output schema\"\n    )]\n    RenderedClassNameCollision {\n        rendered_name: String,\n        first: String,\n        second: String,","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/sys_ops/src/output_format.rs#L1-L31","documentation":"RenderError::ClassNotFound is raised by the sys_ops output_format renderer when a class referenced during output rendering cannot be found in the renderer's type registry. The '{0}' placeholder is the class name. Like EnumNotFound, it indicates a schema lookup failure: the class definition is missing from the loaded types.","triggerScenarios":"Rendering output whose type references a class absent from the loaded BAML sources, or generated code that references a class deleted/renamed since generation.","commonSituations":"Schema files not fully loaded into the renderer, drift between generated client code and current .baml sources, or misspelled class names in dynamic output schemas.","solutions":["Ensure the .baml file defining the class is loaded into the renderer registry","Regenerate client code after class renames or deletions","Correct the class name in the referencing code/template","Verify the renderer is initialized with the same project sources as the runtime"],"exampleFix":"// before\nrender(result, registryMissing(User))  // ClassNotFound('User')\n// after\nconst registry = build_registry([user_baml, ...other_sources]);\nrender(result, registry)","handlingStrategy":"type-guard","validationCode":"function classIsRenderable(registry, name) {\n  return registry.classes.some(c => c.name === name);\n}\n// call before render: classIsRenderable(registry, 'User')","typeGuard":"function isClassNotFoundError(e) {\n  return e instanceof Error && /Class '.*' not found/.test(e.message);\n}","tryCatchPattern":"try {\n  rendered = render(value, registry);\n} catch (e) {\n  if (isClassNotFoundError(e)) {\n    rendered = { __missing_class__: e.message.match(/Class '(.*)' not found/)[1] };\n  } else throw e;\n}","preventionTips":["Ensure every class referenced by output types is loaded into the registry","Regenerate after renaming/deleting classes in .baml files","Validate generated-code class references against current sources in CI","Initialize the renderer with the full project source set"],"tags":["rendering","schema","class"],"backgroundTag":"class-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}