wasmerio/wasmer · error · anyhow::Error
invalid node type returned
Error message
invalid node type returned
What it means
After fetching a GraphQL node by id (get_node), the code expects it to deserialize into the specific variant it needs (here AutobuildRepository, in the path shared by get_engine/compile_wasm/download_and_compile_small). If the backend returns a different Node variant, the match falls through and bails with 'invalid node type returned'.
Source
Thrown at lib/backend-api/src/query.rs:1502
.into_iter()
.flatten()
.filter_map(|x| x.node)
.collect();
Ok(builds)
}
/// Get an app deployment by ID.
pub async fn app_deployment(
client: &WasmerClient,
id: String,
) -> Result<types::AutobuildRepository, anyhow::Error> {
let node = get_node(client, id.clone())
.await?
.with_context(|| format!("app deployment with id '{id}' not found"))?;
match node {
types::Node::AutobuildRepository(x) => Ok(*x),
_ => anyhow::bail!("invalid node type returned"),
}
}
/// Load all versions of an app.
///
/// Will paginate through all versions and return them in a single list.
pub async fn all_app_versions(
client: &WasmerClient,
owner: String,
name: String,
) -> Result<Vec<DeployAppVersion>, anyhow::Error> {
let mut vars = GetDeployAppVersionsVars {
owner,
name,
offset: None,
before: None,
after: None,
first: Some(10),View on GitHub (pinned to 8c4b9ee9d3)
Solutions
- Double-check the id you pass corresponds to the expected entity type (autobuild repository vs deployment vs engine).
- Fetch the node and inspect its __typename/variant first, then route to the correct loader for that variant.
- If a new backend node type appeared, update the match in query.rs to handle/convert it instead of bailing.
Example fix
// before
match node {
types::Node::AutobuildRepository(x) => Ok(*x),
_ => anyhow::bail!("invalid node type returned"),
}
// after
match node {
types::Node::AutobuildRepository(x) => Ok(*x),
other => anyhow::bail!("invalid node type returned: {:?} (id '{id}' is not an autobuild repository)", other),
} Defensive patterns
Strategy: type-guard
Type guard
fn as_autobuild_repository(node: types::Node) -> Option<Box<types::AutobuildRepository>> {
match node {
types::Node::AutobuildRepository(x) => Some(x),
_ => None,
}
} Try / catch
let repo = as_autobuild_repository(node)
.with_context(|| format!("id '{id}' is not an autobuild repository"))?; Prevention
- Track which id belongs to which entity type (deployment vs repository vs engine)
- Inspect the node variant (__typename) before downcasting
- Log the actual variant in the error message to ease diagnosis
When it happens
Trigger: Calling a function like get_app_deployment/get_engine/compile_wasm-related helpers with an id that exists but is not the expected node kind — e.g. passing a Deployment id where an AutobuildRepository id is required.
Common situations: Mixing up app/deployment/repository ids when scripting; backend schema changed so the id now resolves to a new node type; stale ids from an older environment.
Related errors
- user agent must not be empty
- invalid value for {} - expected 0/false|1/true: '{other}'
- cron job '{cron_job}' not found
- invocation start must not be after end
- App deletion failed for an unknown reason
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/d400762f9195c013.
Report an issue: GitHub.