astrid-runtime/astrid · error

[[topic]] ' ' references wit_type ' ' but no WIT record…

Error message

[[topic]] '{}' references wit_type '{}' but no WIT record with that name was found in {}

What it means

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.

Solutions

  1. Fix the wit_type spelling in the [[topic]] entry to match a record in wit/
  2. Add the missing record to a .wit file in the capsule's wit/ directory
  3. Confirm WIT files are located in <capsule>/wit and parse cleanly
  4. Regenerate/sync WIT schemas if the WIT package was updated

Example fix

# before (astrid.toml)
[[topic]]
name = "events"
wit_type = "Evemt"
# after
[[topic]]
name = "events"
wit_type = "Event"
Defensive patterns

Strategy: validation

Validate before calling

fn topic_wit_type_exists(wit_dir: &Path, wit_type: &str) -> Result<(), String> {
    let schemas = WitSchemas::from_dir(wit_dir)
        .map_err(|e| e.to_string())?;
    if schemas.get(wit_type).is_some() { Ok(()) }
    else { Err(format!("WIT record '{}' not found in {}", wit_type, wit_dir.display())) }
}

Type guard

fn wit_schema_defined(schemas: &WitSchemas, wit_type: &str) -> bool {
    schemas.get(wit_type).is_some()
}

Try / catch

match resolve_wit_type(capsule_dir, topic_name, wit_type) {
    Err(e) if e.to_string().contains("no WIT record with that name") => {
        eprintln!("check wit_type spelling against files in wit/");
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/480e3451751afd44. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-build/src/wit_schema.rs:309

/// Resolve a `wit_type` name against parsed WIT schemas for a capsule.
///
/// Reads all `.wit` files from `capsule_dir/wit/`, finds the named record,
/// and returns its JSON Schema.
///
/// # Errors
/// Returns an error if the WIT directory can't be read, WIT files fail to parse,
/// or the named record is not found.
pub fn resolve_wit_type(
    capsule_dir: &Path,
    wit_type: &str,
    topic_name: &str,
) -> anyhow::Result<serde_json::Value> {
    let wit_dir = capsule_dir.join("wit");
    let schemas = WitSchemas::from_dir(&wit_dir)?;

    schemas.get(wit_type).cloned().ok_or_else(|| {
        anyhow::anyhow!(
            "[[topic]] '{}' references wit_type '{}' but no WIT record with that name \
             was found in {}",
            topic_name,
            wit_type,
            wit_dir.display()
        )
    })
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn parse_simple_record() {
        let wit = r"
package test:events@1.0.0;

View on GitHub (pinned to affd8760f4)