{"record":{"id":"d25814073980659f","repo":"facebook/relay","slug":"expected-presence-of-edges-field-to-have-been-prev","errorCode":null,"errorMessage":"Expected presence of edges field to have been previously validated.","messagePattern":"Expected presence of edges field to have been previously validated\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-transforms/src/transform_connections.rs","lineNumber":155,"sourceCode":"    ) -> Vec<Selection> {\n        let is_stream_connection = connection_directive.name.item\n            == self.connection_constants.stream_connection_directive_name;\n        let schema = &self.program.schema;\n        let transformed_selections = self\n            .transform_selections(&connection_field.selections)\n            .replace_or_else(|| connection_field.selections.clone());\n\n        let ((edges_ix, edges_field), page_info_selection) = assert_connection_selections(\n            schema,\n            &transformed_selections,\n            self.connection_interface,\n        );\n        let connection_field_type = schema.field(connection_field.definition.item).type_.inner();\n\n        // Construct edges selection\n        let edges_schema_field_id = schema\n            .named_field(connection_field_type, self.connection_interface.edges)\n            .expect(\"Expected presence of edges field to have been previously validated.\");\n        let edges_schema_field = schema.field(edges_schema_field_id);\n        let edges_field_name = edges_schema_field.name.item;\n        let edge_type = edges_schema_field.type_.inner();\n        let mut is_aliased_edges = false;\n\n        let mut transformed_edges_field = if let Some(alias) = edges_field.alias {\n            is_aliased_edges = true;\n            // The edges selection has to be generated as non-aliased field (since product\n            // code may be accessing the non-aliased response keys).\n            if alias.item != edges_field_name {\n                // If an alias is present, and it is different from the field name,\n                // we need to build a new edges_selection\n                LinkedField {\n                    alias: None,\n                    definition: WithLocation::generated(edges_schema_field_id),\n                    arguments: Vec::new(),\n                    directives: Vec::new(),\n                    selections: Vec::new(),","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-transforms/src/transform_connections.rs#L137-L173","documentation":"When transforming a @connection field, the compiler constructs an edges selection by looking up the edges field on the connection type via schema.named_field(...) and expects it to exist, trusting that connection validation (e.g. validation_rules checking ConnectionInterface compliance) already verified the field. Panicking means a connection-like field lacking an edges field reached the transform anyway.","triggerScenarios":"A field annotated with @connection whose type does not actually implement the connection interface with an edges field, while the preceding connection validation pass was skipped, misconfigured, or the transform order changed.","commonSituations":"Custom connection interface names (ConnectionInterface config) that don't match the schema; hand-written mock/extended schemas missing edges; running transform_connections without validate_connections in the pipeline.","solutions":["Ensure the connection field's type defines an edges field returning an object with a node field.","Check the ConnectionInterface config (edges/page_info field names) matches your schema's actual field names.","Keep the connection validation transform in the pipeline before transform_connections.","Fix the @connection directive placement — it must be on a field whose type is a valid connection."],"exampleFix":"// before: type UserConnection { pageInfo: PageInfo! }  (missing edges)\n// after\ntype UserConnection {\n  edges: [UserEdge!]!\n  pageInfo: PageInfo!\n}","handlingStrategy":"validation","validationCode":"if schema.named_field(conn_type, \"edges\").is_none() {\n    return Err(Diagnostic::error(format!(\"@connection type {:?} has no edges field\", conn_type)));\n}","typeGuard":"fn is_valid_connection(schema: &Schema, t: Type, ci: &ConnectionInterface) -> bool {\n    schema.named_field(t.inner(), ci.edges).is_some()\n}","tryCatchPattern":"let Some(edges_id) = schema.named_field(connection_field_type, self.connection_interface.edges) else {\n    return Err(Diagnostic::error(\"connection field missing edges\"));\n};","preventionTips":["Define edges + pageInfo on every connection type.","Match ConnectionInterface config names to your schema.","Keep validate_connections before transform_connections."],"tags":["relay-compiler","connections","schema"],"backgroundTag":"invalid-connection-field","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}