{"record":{"id":"d400762f9195c013","repo":"wasmerio/wasmer","slug":"invalid-node-type-returned","errorCode":null,"errorMessage":"invalid node type returned","messagePattern":"invalid node type returned","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"lib/backend-api/src/query.rs","lineNumber":1502,"sourceCode":"        .into_iter()\n        .flatten()\n        .filter_map(|x| x.node)\n        .collect();\n\n    Ok(builds)\n}\n\n/// Get an app deployment by ID.\npub async fn app_deployment(\n    client: &WasmerClient,\n    id: String,\n) -> Result<types::AutobuildRepository, anyhow::Error> {\n    let node = get_node(client, id.clone())\n        .await?\n        .with_context(|| format!(\"app deployment with id '{id}' not found\"))?;\n    match node {\n        types::Node::AutobuildRepository(x) => Ok(*x),\n        _ => anyhow::bail!(\"invalid node type returned\"),\n    }\n}\n\n/// Load all versions of an app.\n///\n/// Will paginate through all versions and return them in a single list.\npub async fn all_app_versions(\n    client: &WasmerClient,\n    owner: String,\n    name: String,\n) -> Result<Vec<DeployAppVersion>, anyhow::Error> {\n    let mut vars = GetDeployAppVersionsVars {\n        owner,\n        name,\n        offset: None,\n        before: None,\n        after: None,\n        first: Some(10),","sourceCodeStart":1484,"sourceCodeEnd":1520,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/backend-api/src/query.rs#L1484-L1520","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nmatch node {\n    types::Node::AutobuildRepository(x) => Ok(*x),\n    _ => anyhow::bail!(\"invalid node type returned\"),\n}\n// after\nmatch node {\n    types::Node::AutobuildRepository(x) => Ok(*x),\n    other => anyhow::bail!(\"invalid node type returned: {:?} (id '{id}' is not an autobuild repository)\", other),\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn as_autobuild_repository(node: types::Node) -> Option<Box<types::AutobuildRepository>> {\n    match node {\n        types::Node::AutobuildRepository(x) => Some(x),\n        _ => None,\n    }\n}","tryCatchPattern":"let repo = as_autobuild_repository(node)\n    .with_context(|| format!(\"id '{id}' is not an autobuild repository\"))?;","preventionTips":["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"],"tags":["backend-api","graphql","type-mismatch","validation"],"backgroundTag":"unexpected-node-type","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}