{"record":{"id":"480e3451751afd44","repo":"astrid-runtime/astrid","slug":"topic-references-wit-type-but-no-wit","errorCode":null,"errorMessage":"[[topic]] '{}' references wit_type '{}' but no WIT record with that name was found in {}","messagePattern":"\\[\\[topic\\]\\] '(.+?)' references wit_type '(.+?)' but no WIT record with that name was found in (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-build/src/wit_schema.rs","lineNumber":309,"sourceCode":"\n/// Resolve a `wit_type` name against parsed WIT schemas for a capsule.\n///\n/// Reads all `.wit` files from `capsule_dir/wit/`, finds the named record,\n/// and returns its JSON Schema.\n///\n/// # Errors\n/// Returns an error if the WIT directory can't be read, WIT files fail to parse,\n/// or the named record is not found.\npub fn resolve_wit_type(\n    capsule_dir: &Path,\n    wit_type: &str,\n    topic_name: &str,\n) -> anyhow::Result<serde_json::Value> {\n    let wit_dir = capsule_dir.join(\"wit\");\n    let schemas = WitSchemas::from_dir(&wit_dir)?;\n\n    schemas.get(wit_type).cloned().ok_or_else(|| {\n        anyhow::anyhow!(\n            \"[[topic]] '{}' references wit_type '{}' but no WIT record with that name \\\n             was found in {}\",\n            topic_name,\n            wit_type,\n            wit_dir.display()\n        )\n    })\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn parse_simple_record() {\n        let wit = r\"\npackage test:events@1.0.0;\n","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-build/src/wit_schema.rs#L291-L327","documentation":"A capsule manifest `[[topic]]` entry declares `wit_type`, and resolve_wit_type looks up that name in the WIT schemas parsed from the capsule's `wit/` directory. If no WIT record with that name exists, the build fails with this error naming the topic, the type, and the directory.","triggerScenarios":"resolve_wit_type(capsule_dir, topic_name, wit_type) is called during capsule config resolution and `WitSchemas::from_dir(wit/)` yields no record matching wit_type — typo in wit_type, or the record lives outside the wit dir / was renamed.","commonSituations":"Renaming a WIT record without updating the manifest topic; wit_type pointing to a function or variant instead of a record; wit files placed in the wrong directory so from_dir doesn't see them.","solutions":["Fix the wit_type spelling in the [[topic]] entry to match a record in wit/","Add the missing record to a .wit file in the capsule's wit/ directory","Confirm WIT files are located in <capsule>/wit and parse cleanly","Regenerate/sync WIT schemas if the WIT package was updated"],"exampleFix":"# before (astrid.toml)\n[[topic]]\nname = \"events\"\nwit_type = \"Evemt\"\n# after\n[[topic]]\nname = \"events\"\nwit_type = \"Event\"","handlingStrategy":"validation","validationCode":"fn topic_wit_type_exists(wit_dir: &Path, wit_type: &str) -> Result<(), String> {\n    let schemas = WitSchemas::from_dir(wit_dir)\n        .map_err(|e| e.to_string())?;\n    if schemas.get(wit_type).is_some() { Ok(()) }\n    else { Err(format!(\"WIT record '{}' not found in {}\", wit_type, wit_dir.display())) }\n}","typeGuard":"fn wit_schema_defined(schemas: &WitSchemas, wit_type: &str) -> bool {\n    schemas.get(wit_type).is_some()\n}","tryCatchPattern":"match resolve_wit_type(capsule_dir, topic_name, wit_type) {\n    Err(e) if e.to_string().contains(\"no WIT record with that name\") => {\n        eprintln!(\"check wit_type spelling against files in wit/\");\n    }\n    other => other?,\n}","preventionTips":["Keep wit_type values in sync with WIT record names via codegen or tests","Ensure WIT sources always live in the capsule's wit/ directory","Add a manifest-vs-WIT consistency check to CI"],"tags":["wit","schema","config","manifest"],"backgroundTag":"resource-not-found","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}