{"record":{"id":"320010f74b984edd","repo":"facebook/relay","slug":"extend-type-a-not-found","errorCode":null,"errorMessage":"extend type A not found","messagePattern":"extend type A not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/schema-set/src/build_schema_document.rs","lineNumber":944,"sourceCode":"    fn test_extensions_print_after_definitions() {\n        let doc = parse_schema_document(\n            indoc! {r#\"\n                extend type A implements B {\n                  id: ID\n                }\n\n                interface B {\n                  id: ID\n                }\n            \"#},\n            SourceLocationKey::generated(),\n        )\n        .unwrap();\n        let set = SchemaSet::from_schema_documents_with_extensions(&[], &[doc]).unwrap();\n        let sdl = format!(\"{}\", set.to_sdl_definition());\n\n        let interface_pos = sdl.find(\"interface B\").expect(\"interface B not found\");\n        let extension_pos = sdl.find(\"extend type A\").expect(\"extend type A not found\");\n        assert!(\n            interface_pos < extension_pos,\n            \"Definitions should print before extensions: {}\",\n            sdl,\n        );\n    }\n\n    #[test]\n    fn test_object_fields_sorted_alphabetically() {\n        let sdl = schema_sdl(indoc! {r#\"\n            type Foo {\n              zebra: String\n              apple: Int\n              mango: Boolean\n            }\n        \"#});\n        // Fields should be sorted alphabetically\n        let apple_pos = sdl.find(\"apple\").expect(\"apple not found\");","sourceCodeStart":926,"sourceCodeEnd":962,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/schema-set/src/build_schema_document.rs#L926-L962","documentation":"Panic from `.expect(\"extend type A not found\")` in `test_extensions_print_after_definitions` (compiler/crates/schema-set/src/build_schema_document.rs:944), in the same test as error 161. The printed SDL from `set.to_sdl_definition()` contains no `extend type A` substring. The test's purpose is that base definitions print before extensions, so if the extension is missing entirely the ordering guarantee cannot be verified and the library panics via `.expect`.","triggerScenarios":"Calling `SchemaSet::from_schema_documents_with_extensions(&[], &[doc])` where `doc` declares `extend type A implements B`, then printing with `to_sdl_definition()` and finding the extension absent — e.g. the printer merged the extension into a single `type A` definition, dropped extensions that reference not-yet-defined interfaces, or the extension document was parsed into a bucket that `to_sdl_definition` ignores.","commonSituations":"A printer change that flattens type extensions into base type definitions; extensions silently discarded during schema-set build because the base type `A` is not itself defined in the non-extension documents; test input edited so the extension no longer matches the searched string.","solutions":["Print the actual `sdl` output and inspect how `type A`/`extend type A` is rendered; adjust the assertion if formatting changed but semantics are intact.","Check that `from_schema_documents_with_extensions` retains extension documents and that `to_sdl_definition` iterates them; if extensions are being folded into base definitions, that is a printer regression to fix in build_schema_document.rs.","Ensure the base type `A` exists (the test relies on `A` being defined only via extension, which some validators reject — consider defining `type A` base too if the builder drops orphan extensions).","Replace `.expect` with a panic that dumps the SDL so future failures are self-explanatory."],"exampleFix":"// before\nlet extension_pos = sdl.find(\"extend type A\").expect(\"extend type A not found\");\n// after\nlet extension_pos = sdl\n    .find(\"extend type A\")\n    .unwrap_or_else(|| panic!(\"extend type A not found in SDL:\\n{}\", sdl));","handlingStrategy":"validation","validationCode":"// Validate the SDL contains the extension before comparing positions:\nassert!(\n    sdl.contains(\"extend type A\"),\n    \"SDL missing 'extend type A'; extensions may be merged or dropped:\\n{}\",\n    sdl\n);","typeGuard":"fn prints_extension(sdl: &str, type_name: &str) -> bool {\n    sdl.contains(&format!(\"extend type {}\", type_name))\n}","tryCatchPattern":"let extension_pos = sdl\n    .find(\"extend type A\")\n    .unwrap_or_else(|| panic!(\"extend type A not found; SDL was:\\n{}\", sdl));","preventionTips":["Ensure extension documents reference a base type that survives schema-set build; orphan extensions are the first thing printers drop.","Treat printer changes that fold `extend type X` into `type X` as breaking changes and update string-based tests deliberately.","Include the SDL in every assertion message for printed-output tests.","Run `cargo test -p schema-set` after touching `to_sdl_definition` or `from_schema_documents_with_extensions`."],"tags":["rust","panic","sdl-printer","graphql-extensions"],"backgroundTag":"expect-panic-not-found","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}