facebook/relay · error
interface B not found
Error message
interface B not found
What it means
Panic from `.expect("interface B not found")` in `test_extensions_print_after_definitions` (compiler/crates/schema-set/src/build_schema_document.rs:943). The test builds a SchemaSet containing `extend type A implements B` plus `interface B`, prints it with `set.to_sdl_definition()`, then searches the printed SDL for the substring `interface B`. The panic means the printed SDL contains no `interface B` definition at all — the printer dropped the interface, printed it under a different name/keyword, or the schema build failed to retain it.
Source
Thrown at compiler/crates/schema-set/src/build_schema_document.rs:943
#[test]
fn test_extensions_print_after_definitions() {
let doc = parse_schema_document(
indoc! {r#"
extend type A implements B {
id: ID
}
interface B {
id: ID
}
"#},
SourceLocationKey::generated(),
)
.unwrap();
let set = SchemaSet::from_schema_documents_with_extensions(&[], &[doc]).unwrap();
let sdl = format!("{}", set.to_sdl_definition());
let interface_pos = sdl.find("interface B").expect("interface B not found");
let extension_pos = sdl.find("extend type A").expect("extend type A not found");
assert!(
interface_pos < extension_pos,
"Definitions should print before extensions: {}",
sdl,
);
}
#[test]
fn test_object_fields_sorted_alphabetically() {
let sdl = schema_sdl(indoc! {r#"
type Foo {
zebra: String
apple: Int
mango: Boolean
}
"#});
// Fields should be sorted alphabeticallyView on GitHub (pinned to 668b1b85e0)
Solutions
- Print/debug the SDL string on failure (the adjacent assert already embeds `{}` — temporarily print `sdl` before `.find`) and check how `interface B` is actually rendered (maybe `interface B implements` or different spacing).
- Verify the document passed to `from_schema_documents_with_extensions` still declares `interface B` and that the set build `.unwrap()` succeeded.
- Inspect `to_sdl_definition`'s printer to confirm interfaces are emitted as base definitions before extensions; fix the printer if it drops or reorders them.
- If rendering changed legitimately (e.g. keyword/spacing), update the test's search string accordingly.
Example fix
// before
let interface_pos = sdl.find("interface B").expect("interface B not found");
// after
let interface_pos = sdl
.find("interface B")
.unwrap_or_else(|| panic!("interface B not found in SDL:\n{}", sdl)); Defensive patterns
Strategy: validation
Validate before calling
// Validate the set retains the interface before printing:
let sdl = format!("{}", set.to_sdl_definition());
assert!(sdl.contains("interface B"), "SDL missing interface B:\n{}", sdl); Type guard
fn prints_interface(sdl: &str, name: &str) -> bool {
sdl.contains(&format!("interface {}", name))
} Try / catch
// Prefer explicit failure with context over a bare expect:
let interface_pos = match sdl.find("interface B") {
Some(p) => p,
None => panic!("interface B not found in printed SDL:\n{}", sdl),
}; Prevention
- Always include the printed SDL in the panic/assert message when testing printed output.
- Verify schema-set construction succeeded (check the `.unwrap()` before printing) before blaming the printer.
- When changing printer emission rules, run the full schema-set test suite — ordering/printing tests are string-sensitive.
- Keep search substrings minimal but stable (avoid depending on incidental whitespace).
When it happens
Trigger: Calling `SchemaSet::from_schema_documents_with_extensions` with a document containing an `interface B` definition, then calling `to_sdl_definition()` and finding that the interface definition is absent from the output string (e.g. interfaces are only emitted when implemented-and-registered, or the printer skips unextended interfaces).
Common situations: A change in the SDL printer's emission order or filtering rules that drops interface definitions; building the set only from extension documents without registering base definitions; the interface renamed in the test input while the assertion still searches for the old string.
Related errors
- Expected docblocks to only expose object and scalar definiti
- Node.search exists
- extend type A not found
- apple not found
- mango not found
AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02).
Data as JSON: /api/errors/526d04d19d55354f.
Report an issue: GitHub.