facebook/relay · error
zebra not found
Error message
zebra not found
What it means
This is a test assertion panic inside build_schema_document.rs, not a runtime library error. A test generates SDL for a schema document and calls `sdl.find("zebra")`, expecting a field (or type at line 1190) named 'zebra' to appear in the rendered SDL. The expect() failed, meaning the rendered output never contained the literal 'zebra', so the field/type was not emitted or not emitted with that exact spelling.
Source
Thrown at compiler/crates/schema-set/src/build_schema_document.rs:964
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 alphabetically
let apple_pos = sdl.find("apple").expect("apple not found");
let mango_pos = sdl.find("mango").expect("mango not found");
let zebra_pos = sdl.find("zebra").expect("zebra not found");
assert!(
apple_pos < mango_pos && mango_pos < zebra_pos,
"Fields should be sorted: {}",
sdl,
);
}
// --- Interface ---
#[test]
fn test_interface_with_fields() {
let sdl = schema_sdl(indoc! {r#"
interface Node {
id: ID!
}
"#});
assert!(sdl.contains("interface Node"), "Got: {}", sdl);
assert!(sdl.contains("id: ID!"), "Got: {}", sdl);View on GitHub (pinned to 668b1b85e0)
Solutions
- Print the `sdl` string (the panic already shows it via the assert message context, but the expect fails before) — add a debug print of `sdl` before the find calls and inspect why 'zebra' is absent.
- Verify the test fixture still defines the zebra field/type and that the builder includes it in the output document.
- Check for exact-match issues: the SDL may print the field with different casing or as `zebra:` vs `zebra(` — loosen the assertion or fix the printer to match the expected SDL format.
- If field/type sorting was intentionally changed, update the test's expectations to match the new sorted output.
- Run `cargo test -p schema-set` with `--nocapture` to see full SDL output and diff against the expected snapshot.
Example fix
// before
let zebra_pos = sdl.find("zebra").expect("zebra not found");
// after
let zebra_pos = sdl
.find("zebra")
.unwrap_or_else(|| panic!("zebra not found in SDL:\n{}", sdl)); Defensive patterns
Strategy: validation
Validate before calling
let zebra_pos = sdl.find("zebra").unwrap_or_else(|| panic!("zebra not found in SDL:\n{}", sdl)); Type guard
fn position_of(sdl: &str, needle: &str) -> Option<usize> {
sdl.find(needle)
} Prevention
- Use unwrap_or_else with a panic message that prints the full SDL for debuggability.
- Add snapshot tests of the rendered SDL so changes to printing are caught explicitly.
- Keep fixture schemas and expected field names in sync when modifying the builder.
- Run the schema-set test suite after any change to document printing or sorting logic.
When it happens
Trigger: Running the schema-set tests when `build_schema_document` (or `test_printed_fields_sorted`'s fixture schema) fails to include the 'zebra' field in the printed SDL — e.g. the builder dropped the field, renamed/cased it, filtered it, or field/type sorting output changed so the printed name differs from the searched literal.
Common situations: Developers hit this after modifying the schema document builder (changing print order, filtering fields, changing naming conventions), after updating fixture schemas, or when refactoring the test schema inputs so the 'zebra' test entity no longer exists in the built document.
Related errors
- Expected a key
- Unexpected DynamicImport
- Unexpected RelayResolver
- Expected at least one of an @updatable reader AST, or normal
- Expected to have a reader operation for `{normal_name}`
AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02).
Data as JSON: /api/errors/e84114546bb9e3c0.
Report an issue: GitHub.