{"record":{"id":"df44553797259e3b","repo":"facebook/relay","slug":"apple-not-found","errorCode":null,"errorMessage":"apple not found","messagePattern":"apple not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/schema-set/src/build_schema_document.rs","lineNumber":962,"sourceCode":"        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\");\n        let mango_pos = sdl.find(\"mango\").expect(\"mango not found\");\n        let zebra_pos = sdl.find(\"zebra\").expect(\"zebra not found\");\n        assert!(\n            apple_pos < mango_pos && mango_pos < zebra_pos,\n            \"Fields should be sorted: {}\",\n            sdl,\n        );\n    }\n\n    // --- Interface ---\n\n    #[test]\n    fn test_interface_with_fields() {\n        let sdl = schema_sdl(indoc! {r#\"\n            interface Node {\n              id: ID!\n            }\n        \"#});","sourceCodeStart":944,"sourceCodeEnd":980,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/schema-set/src/build_schema_document.rs#L944-L980","documentation":"Panic from `.expect(\"apple not found\")` in `test_object_fields_sorted_alphabetically` (compiler/crates/schema-set/src/build_schema_document.rs:962). The test declares `type Foo` with fields `zebra`, `apple`, `mango` in non-alphabetical order, prints the schema SDL, and asserts the substring positions are sorted. The panic means the printed SDL contains no `apple` field — the type or its fields were dropped from the output, or the SDL text no longer declares that field.","triggerScenarios":"Building a schema from SDL with `type Foo { zebra: String apple: Int mango: Boolean }` via the `schema_sdl` helper, calling `to_sdl_definition()`, and finding the field `apple` missing from the printed output (printer emits no fields, or emits a different type shape).","commonSituations":"A printer regression that drops object fields or the whole object type; the test SDL edited (field renamed/removed) without updating the assertion; field printing only for types reachable from the query root, and `Foo` being unreachable.","solutions":["Print the failing `sdl` and check whether `type Foo` and its fields appear at all; if `Foo` is missing entirely, investigate why the printer emits unreachable types differently.","Confirm the test SDL still declares `apple: Int` inside `type Foo` and the substring matches exactly.","Inspect the field-printing/ordering logic in build_schema_document.rs (the sorted-fields printer) for regressions that skip fields.","Swap `.expect` for a panic that includes the SDL so the actual output is visible on failure."],"exampleFix":"// before\nlet apple_pos = sdl.find(\"apple\").expect(\"apple not found\");\n// after\nlet apple_pos = sdl\n    .find(\"apple\")\n    .unwrap_or_else(|| panic!(\"apple not found in SDL:\\n{}\", sdl));","handlingStrategy":"validation","validationCode":"// Check all expected fields exist before asserting order:\nfor f in [\"apple\", \"mango\", \"zebra\"] {\n    assert!(sdl.contains(f), \"SDL missing field '{}'\\n{}\", f, sdl);\n}","typeGuard":"fn prints_field(sdl: &str, field: &str) -> bool {\n    sdl.split_whitespace().any(|tok| tok.starts_with(field))\n}","tryCatchPattern":"let apple_pos = sdl\n    .find(\"apple\")\n    .unwrap_or_else(|| panic!(\"apple not found; SDL:\\n{}\", sdl));","preventionTips":["Pre-assert each expected substring before positional comparisons so the failure names the missing item.","Keep test SDL fixtures and lookup strings in sync — update all lookups when editing the fixture.","If printed output is unreachable-type-sensitive, route the type through the query root or configure the printer to emit all definitions.","Use assertion messages that embed the full SDL for fast diagnosis."],"tags":["rust","panic","sdl-printer","test-assertion"],"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"}