{"record":{"id":"fa66b04a164e557d","repo":"facebook/relay","slug":"expected-an-ir-that-models-a-field","errorCode":null,"errorMessage":"Expected an IR that models a field","messagePattern":"Expected an IR that models a field","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-compiler/src/build_project/build_resolvers_schema/extract_docblock_ir.rs","lineNumber":168,"sourceCode":"            .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);\n\nfn extract_schema_documents_for_resolvers<'a>(\n    project_name: &'a ProjectName,\n    compiler_state: &'a CompilerState,\n    graphql_asts_map: &'a FnvHashMap<ProjectName, GraphQLAsts>,\n) -> DiagnosticsResult<ResolverSchemaDocuments<'a>> {\n    let docblock_ast_sources = (","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-compiler/src/build_project/build_resolvers_schema/extract_docblock_ir.rs#L150-L186","documentation":"expect_field_ir unwraps a DocblockIr and panics unless it is the Field variant. A docblock expected to describe a resolver field produced some other IR (e.g. Type), so the field-extraction invariant was violated.","triggerScenarios":"ExtractedDocblockIr processes a field docblock (e.g. @RelayResolver on a function/property) but the docblock compiles to DocblockIr::Type or another non-field variant.","commonSituations":"A type-level docblock placed on a field, or a resolver file whose docblocks were reordered/renamed after a Relay version change, changing IR classification.","solutions":["Move the docblock onto the field/function declaration it describes","Verify the docblock tags indicate a field (e.g. @RelayResolver with a return type) not a type definition","Check Relay version migration notes for docblock IR classification changes"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if let DocblockIr::Field(_) = docblock_ir {\n    let field_ir = expect_field_ir(docblock_ir);\n}","typeGuard":"fn as_field_ir(ir: DocblockIr) -> Option<ResolverFieldDocblockIr> {\n    match ir {\n        DocblockIr::Field(f) => Some(f),\n        _ => None,\n    }\n}","tryCatchPattern":"// not catchable; use as_field_ir and report a diagnostic naming the docblock source location","preventionTips":["Attach field docblocks only to fields/functions, not type declarations","Re-check docblock placement after Relay upgrades","Validate docblock IR kind before unwrapping in 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"}