{"record":{"id":"c8e22d09387a32eb","repo":"facebook/relay","slug":"unexpected-dynamicimport","errorCode":null,"errorMessage":"Unexpected DynamicImport","messagePattern":"Unexpected DynamicImport","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-codegen/src/printer.rs","lineNumber":936,"sourceCode":"                    if !obj.is_empty() {\n                        f.pop();\n                    }\n                    f.push('}');\n                    Ok(())\n                }\n            }\n        }\n        Primitive::Null | Primitive::SkippableNull => {\n            f.push_str(\"null\");\n            Ok(())\n        }\n        Primitive::StorageKey(_, _) => panic!(\"Unexpected StorageKey\"),\n        Primitive::RawString(_) => panic!(\"Unexpected RawString\"),\n        Primitive::GraphQLModuleDependency(_) => panic!(\"Unexpected GraphQLModuleDependency\"),\n        Primitive::JSModuleDependency { .. } => panic!(\"Unexpected JSModuleDependency\"),\n        Primitive::ResolverModuleReference { .. } => panic!(\"Unexpected ResolverModuleReference\"),\n        Primitive::PropertyAccessor(_) => panic!(\"Unexpected PropertyAccessor\"),\n        Primitive::DynamicImport { .. } => panic!(\"Unexpected DynamicImport\"),\n        Primitive::RelayResolverModel { .. } => panic!(\"Unexpected RelayResolver\"),\n    }\n}\n","sourceCodeStart":918,"sourceCodeEnd":940,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-codegen/src/printer.rs#L918-L940","documentation":"This is an internal compiler invariant panic in write_constant_value. The printer encountered a Primitive::DynamicImport where the schema only allows true constant values (strings, booleans, enums, etc.). DynamicImport primitives are only valid in resolver export positions, never as an argument or constant.","triggerScenarios":"Calling write_argument_value or write_constant_value with a Primitive::DynamicImport node — i.e. a schema/resolver value that resolved to a dynamic import reaching the constant-printing path.","commonSituations":"A Relay resolver or module dependency (@module) incorrectly typed/positioned so a dynamic import is treated as a literal constant during codegen; usually a compiler bug or malformed resolver definition.","solutions":["Check whether the resolver/JS module import is used in a position requiring a literal constant and move it to a valid export/dependency position","Verify your resolver type annotations so @module/dynamic imports are not inferred as constants","Reproduce with a minimal schema and file an issue against the Relay compiler (likely a codegen bug)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Rust caller: ensure the primitive is a printable constant before printing\nmatch primitive {\n    Primitive::DynamicImport { .. } => panic/handle: route dynamic imports to the module/export printer path instead,\n    _ => write_constant_value(primitive),\n}","typeGuard":"fn is_constant_printable(p: &Primitive) -> bool {\n    !matches!(p, Primitive::DynamicImport { .. } | Primitive::RelayResolverModel { .. })\n}","tryCatchPattern":"// panics are not catchable idiomatically; pre-validate with is_constant_printable before calling","preventionTips":["Never pass module/dynamic-import primitives into constant argument printing","Route @module dependencies through the dedicated dependency printer","Add a compile-time/debug assertion upstream when constructing Primitive values"],"tags":["compiler","rust","panic","codegen","internal-invariant"],"backgroundTag":"compiler-internal-invariant-panic","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}