clockworklabs/SpacetimeDB · error

Invalid entity_type '{}'. Expected one of: reducer, table.

Error message

Invalid entity_type '{}'. Expected one of: reducer, table.

What it means

`spacetime describe` accepts an optional (entity_type, entity_name) pair after the database, and entity_type must be exactly 'reducer' or 'table' (lowercase). Any other word is rejected before the database schema is consulted. Note the argument grammar is strict: you must pass both entity_type and entity_name or neither.

Source

Thrown at crates/cli/src/subcommands/describe.rs:74

    let no_config = args.get_flag("no_config");
    let raw_parts: Vec<String> = args
        .get_many::<String>("describe_parts")
        .map(|vals| vals.cloned().collect())
        .unwrap_or_default();
    let config_targets = load_config_db_targets(no_config)?;
    let resolved = resolve_database_with_optional_parts(
        &raw_parts,
        config_targets.as_deref(),
        "spacetime describe [database] [entity_type entity_name] --json [--no-config]",
    )?;
    let entity = match resolved.remaining_args.as_slice() {
        [] => None,
        [entity_type, entity_name] => {
            let entity_type = match entity_type.as_str() {
                "reducer" => EntityType::Reducer,
                "table" => EntityType::Table,
                _ => {
                    anyhow::bail!(
                        "Invalid entity_type '{}'. Expected one of: reducer, table.",
                        entity_type
                    )
                }
            };
            Some((entity_type, entity_name.as_str()))
        }
        _ => {
            anyhow::bail!(
                "Invalid describe arguments.\nUsage: spacetime describe [database] [entity_type entity_name] --json [--no-config]"
            );
        }
    };

    let mut config = config;
    let server_from_cli = args.get_one::<String>("server").map(|s| s.as_ref());
    let server = server_from_cli.or(resolved.server.as_deref());
    let force = args.get_flag("force");

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Use exactly `reducer` or `table` (lowercase, singular)
  2. To inspect other entity kinds, run `spacetime describe <db>` for the full schema (add --json and filter with jq)

Example fix

# before
spacetime describe mydb View user_view

# after
spacetime describe mydb   # full schema, then find the view in --json output
Defensive patterns

Strategy: type-guard

Validate before calling

# Whitelist entity types before invoking the CLI
ETYPES='reducer table'
[ $# -ge 2 ] && case " $ETYPES " in *" $1 "*) ;; *) echo "entity_type must be: $ETYPES" >&2; exit 2;; esac
spacetime describe "$DB" "$@"

Type guard

fn entity_type(s: &str) -> Option<EntityType> {
    match s {
        "reducer" => Some(EntityType::Reducer),
        "table" => Some(EntityType::Table),
        _ => None,
    }
}

Try / catch

match entity_type(word) {
    Some(t) => describe(db, t, name).await,
    None => anyhow::bail!("entity_type must be 'reducer' or 'table', got '{word}'"),
}

Prevention

When it happens

Trigger: `spacetime describe <db> <type> <name>` where <type> is not the literal string 'reducer' or 'table' — e.g. 'view', 'entity', 'Table', or pluralized forms.

Common situations: Assuming newer schema entity kinds (views, types) are describable; capitalized or pluralized keywords; copy-pasting entity kinds from other tools' conventions.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/a91f5a1594c63f8a. Report an issue: GitHub.