{"record":{"id":"cca6690810bcc4c4","repo":"dbt-labs/dbt-core","slug":"metadata-query-plan-always-includes-metadata-opera","errorCode":null,"errorMessage":"metadata query plan always includes metadata operation","messagePattern":"metadata query plan always includes metadata operation","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/metadata/snowflake/mod.rs","lineNumber":847,"sourceCode":"            metadata_warehouse.clone(),\n            token.clone(),\n            Box::new(AdapterConnectionFactory::new(\n                self.adapter.engine().clone(),\n                self.adapter.engine().threads(),\n            )),\n        ));\n\n        let adapter = self.adapter.clone();\n        let token_clone = token.clone();\n\n        let map_f = move |conn: &'_ mut dyn Connection,\n                          db_schema: &CatalogAndSchema|\n              -> AdapterResult<Vec<Arc<dyn BaseRelation>>> {\n            let plan = snowflake_list_relations_query_plan(metadata_warehouse.as_deref());\n            let _metadata_operation = plan\n                .statements\n                .last()\n                .expect(\"metadata query plan always includes metadata operation\");\n            let query_ctx = QueryCtx::default().with_desc(\"list_relations_in_parallel\");\n            adapter.list_relations(&query_ctx, conn, db_schema, token_clone.clone())\n        };\n\n        let reduce_f = move |acc: &mut Acc,\n                             db_schema: CatalogAndSchema,\n                             relations: AdapterResult<Vec<Arc<dyn BaseRelation>>>|\n              -> Result<(), Cancellable<AdapterError>> {\n            match relations {\n                Ok(relations) => {\n                    acc.insert(db_schema, Ok(relations));\n                    Ok(())\n                }\n                Err(e) => {\n                    // Empty schema error code - no relations in this schema\n                    // XXX: The AdapterError struct is not properly being built at the moment, rely on string search for now\n                    if e.message().contains(\"Object does not exist\") {\n                        acc.insert(db_schema, Ok(Vec::new()));","sourceCodeStart":829,"sourceCodeEnd":865,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/metadata/snowflake/mod.rs#L829-L865","documentation":"Internal invariant expect in list_relations_in_parallel_inner_with_options: building the Snowflake list-relations query plan must always yield a plan containing the metadata operation, and the unwrap of that construction failed. This is not user input related — it fires only if the query-plan builder regresses or returns an unexpected plan shape.","triggerScenarios":"Thrown at crates/dbt-adapter/src/metadata/snowflake/mod.rs:847 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the metadata query plan construction (snowflake_list_relations_query_plan) for changes that drop the metadata operation","Report as an internal bug — no adapter configuration triggers this","Add a regression test pinning the metadata operation in the generated plan"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}