{"record":{"id":"e0eb52cc9b201ede","repo":"facebook/relay","slug":"expected-an-ir-that-models-a-type","errorCode":null,"errorMessage":"Expected an IR that models a type","messagePattern":"Expected an IR that models a type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-compiler/src/build_project/build_resolvers_schema/extract_docblock_ir.rs","lineNumber":161,"sourceCode":"            .map(|docblock_ir| {\n                let ir = expect_type_ir(docblock_ir);\n                AllocatedDocblockIr { ir, is_base }\n            })\n            .collect(),\n        field_irs: field_irs\n            .into_iter()\n            .map(|docblock_ir| {\n                let ir = expect_field_ir(docblock_ir);\n                AllocatedDocblockIr { ir, is_base }\n            })\n            .collect(),\n    })\n}\n\nfn expect_type_ir(docblock_ir: relay_docblock::DocblockIr) -> ResolverTypeDocblockIr {\n    match docblock_ir {\n        DocblockIr::Type(ir) => ir,\n        _ => panic!(\"Expected an IR that models a type\"),\n    }\n}\n\nfn expect_field_ir(docblock_ir: relay_docblock::DocblockIr) -> ResolverFieldDocblockIr {\n    match docblock_ir {\n        DocblockIr::Field(ir) => ir,\n        _ => panic!(\"Expected an IR that models a field\"),\n    }\n}\n\nstruct ResolverSchemaDocuments<'a> {\n    type_asts: TypeAsts,\n    field_asts_and_definitions: FieldAstsAndDefinitions<'a>,\n}\nstruct TypeAsts(Vec<DocblockAST>);\nstruct FieldAstsAndDefinitions<'a>(\n    FxHashMap<&'a PathBuf, (Vec<DocblockAST>, Option<&'a Vec<ExecutableDefinition>>)>,\n);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-compiler/src/build_project/build_resolvers_schema/extract_docblock_ir.rs#L143-L179","documentation":"expect_type_ir unwraps a DocblockIr and panics unless it is the Type variant. A docblock (e.g. @RelayResolver type doc) that should describe a GraphQL type produced a different IR (field or other), meaning the docblock was parsed/classified unexpectedly.","triggerScenarios":"ExtractedDocblockIr processes a docblock expected to define or extend a type (e.g. from @RelayResolver on a type-level docblock) but the docblock compiles to DocblockIr::Field or another variant.","commonSituations":"Misplaced docblock — a field-level docblock where a type docblock is expected, or an @RelayResolver docblock attached to the wrong kind of definition in a resolver file.","solutions":["Move the docblock to the correct declaration (type-level vs field-level)","Check the docblock directive tags (@RelayResolver vs field tags) match what the declaration models","Fix syntax that makes the docblock parser classify it as a field IR instead of a type IR"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Before unwrapping, check the variant\nif let DocblockIr::Type(_) = docblock_ir {\n    let type_ir = expect_type_ir(docblock_ir);\n}","typeGuard":"fn as_type_ir(ir: DocblockIr) -> Option<ResolverTypeDocblockIr> {\n    match ir {\n        DocblockIr::Type(t) => Some(t),\n        _ => None,\n    }\n}","tryCatchPattern":"// not catchable; use as_type_ir and emit a compiler diagnostic instead of unwrapping","preventionTips":["Attach type docblocks only to type declarations","Match docblock tags to the declaration kind","Prefer Option-returning extraction over panic in extraction helpers"],"tags":["compiler","rust","panic","docblock","resolver-schema"],"backgroundTag":"docblock-misplacement","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}