{"record":{"id":"68a92dc6864bfe6d","repo":"dbt-labs/dbt-core","slug":"macro-still-present","errorCode":null,"errorMessage":"macro still present","messagePattern":"macro still present","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-parser/src/resolve/resolve_macros.rs","lineNumber":942,"sourceCode":"            relative_path: PathBuf::from(\"macros/schema.yml\"),\n            schema_value,\n            table_value: None,\n            version_info: None,\n            duplicate_paths: vec![],\n        };\n        let macro_properties = BTreeMap::from([(\"my_macro\".to_string(), props_entry)]);\n\n        apply_macro_patches(\n            &mut macros,\n            &macro_properties,\n            \"test_pkg\",\n            &jinja_env,\n            &base_ctx,\n            None,\n            false,\n        )?;\n\n        let patched = macros.get(&unique_id).expect(\"macro still present\");\n\n        // config.meta mirrors the patched meta\n        let owner = patched\n            .config\n            .meta\n            .get(\"owner\")\n            .expect(\"owner key in config.meta\");\n        assert_eq!(owner.as_str(), Some(\"alice\"));\n\n        // config.docs mirrors the patched docs (show: false)\n        assert!(\n            !patched.config.docs.show,\n            \"config.docs.show should be false\"\n        );\n\n        Ok(())\n    }\n","sourceCodeStart":924,"sourceCodeEnd":960,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-parser/src/resolve/resolve_macros.rs#L924-L960","documentation":"Test assertion \"macro still present\" panics when `macros.get(&unique_id)` returns None after applying macro patches in test_apply_macro_patches_populates_config_meta_and_docs. It verifies that apply_macro_patches never removes or renames the patched macro's entry in the macros map.","triggerScenarios":"apply_macro_patches (called with &jinja_env, &base_ctx, None, false) fails to insert/retain the macro keyed by unique_id, so the subsequent map lookup yields None.","commonSituations":"A change to patch keying (e.g., switching from name to unique_id, or package-qualified IDs) makes the patch land under a different key; the patch fixture macro name was renamed so no entry is created.","solutions":["Print/inspect the keys of the macros map after apply_macro_patches and compare against unique_id to find the key mismatch.","Ensure the test fixture macro's name/package produces the same unique_id used for the lookup.","Check that apply_macro_patches inserts the patched macro rather than only mutating config in place."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// after apply_macro_patches\nassert!(macros.contains_key(&unique_id), \"patch key {} missing; keys: {:?}\", unique_id, macros.keys().collect::<Vec<_>>());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep patch keying consistent (same unique_id scheme for lookup and insertion)","Log macro-map keys when a patch lookup fails","Test patches with package-qualified macro names"],"tags":["rust","test-assertion","macros","parser"],"backgroundTag":"internal-invariant-violation","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}