{"record":{"id":"a9a02bab0137cc36","repo":"swc-project/swc","slug":"unable-to-access-unknown-nodes-a9a02b","errorCode":null,"errorMessage":"unable to access unknown nodes","messagePattern":"unable to access unknown nodes","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_estree_compat/src/babelify/module_decl.rs","lineNumber":267,"sourceCode":"            // map cleanly to\n            // TsInterfaceDecl\n            // expected by swc\n            #[cfg(swc_ast_unknown)]\n            _ => panic!(\"unable to access unknown nodes\"),\n        }\n    }\n}\n\nimpl Babelify for ImportSpecifier {\n    type Output = ImportSpecifierType;\n\n    fn babelify(self, ctx: &Context) -> Self::Output {\n        match self {\n            ImportSpecifier::Named(s) => ImportSpecifierType::Import(s.babelify(ctx)),\n            ImportSpecifier::Default(s) => ImportSpecifierType::Default(s.babelify(ctx)),\n            ImportSpecifier::Namespace(s) => ImportSpecifierType::Namespace(s.babelify(ctx)),\n            #[cfg(swc_ast_unknown)]\n            _ => panic!(\"unable to access unknown nodes\"),\n        }\n    }\n}\n\nimpl Babelify for ImportDefaultSpecifier {\n    type Output = BabelImportDefaultSpecifier;\n\n    fn babelify(self, ctx: &Context) -> Self::Output {\n        BabelImportDefaultSpecifier {\n            base: ctx.base(self.span),\n            local: self.local.babelify(ctx),\n        }\n    }\n}\n\nimpl Babelify for ImportStarAsSpecifier {\n    type Output = ImportNamespaceSpecifier;\n","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_estree_compat/src/babelify/module_decl.rs#L249-L285","documentation":"This Babelify impl maps an ImportSpecifier (named, default, or namespace import) to the corresponding Babel specifier type. The `#[cfg(swc_ast_unknown)]` wildcard is compiled only in builds passing `--cfg=swc_ast_unknown` (the cfg SWC plugin builds use to mark swc_ecma_ast enums non_exhaustive for cross-version tolerance). Hitting the panic means the ImportSpecifier value carries a variant the linked swc_ecma_ast version does not define — i.e. the AST came from a different swc version than the one compiled in.","triggerScenarios":"Babelifying import statements whose specifier enum arrived from a newer/older swc_ecma_ast — across a plugin ABI boundary, a mixed-version Cargo graph, or AST deserialization from a different producer version.","commonSituations":"Plugin/wasm artifacts built against an older swc_core running on a newer host; partial swc upgrades; duplicate swc_ecma_ast versions resolved through different dependency paths.","solutions":["Unify versions: `cargo tree -i swc_ecma_ast` should list exactly one; depend via swc_core","Upgrade swc_estree_compat in the same change as swc_ecma_ast so new specifier variants are handled","Rebuild the plugin/wasm boundary with the host's swc version","Use catch_unwind around babelify to fail per-file while versions are migrated"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn import_specifier_known(s: &ImportSpecifier) -> bool {\n    matches!(s, ImportSpecifier::Named(_) | ImportSpecifier::Default(_) | ImportSpecifier::Namespace(_))\n}","tryCatchPattern":"let out = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| program.babelify(&ctx)))\n    .map_err(|_| anyhow::anyhow!(\"babelify failed: swc_ecma_ast version mismatch (unknown ImportSpecifier)\"))?;","preventionTips":["Enforce a single swc_ecma_ast version in the dependency graph","Rebuild plugin/wasm artifacts with each host swc upgrade","Track swc release notes for new specifier variants","Smoke-test babelify on import-heavy fixtures after upgrades"],"tags":["swc","babelify","panic","version-mismatch","non-exhaustive","import-specifier"],"backgroundTag":"ast-version-mismatch","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}