{"record":{"id":"a7f531bec6d9ffc0","repo":"hasura/graphql-engine","slug":"duplicate-order-by-expression-found-order-by-exp","errorCode":null,"errorMessage":"Duplicate order by expression found: {order_by_expression}","messagePattern":"Duplicate order by expression found: (.+?)","errorType":"validation","errorClass":"OrderByExpressionIssue","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/order_by_expressions/types.rs","lineNumber":107,"sourceCode":"    pub order_by_expression_identifier: Qualified<OrderByExpressionIdentifier>,\n}\n\n#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]\npub struct OrderableRelationship {\n    /// order_by_expression is optional.\n    /// If not present we will use order_by_expression from the model\n    /// that the relationship targets.\n    pub order_by_expression: Option<Qualified<OrderByExpressionName>>,\n}\n\n#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]\npub struct OrderByExpressionGraphqlConfig {\n    pub expression_type_name: ast::TypeName,\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum OrderByExpressionIssue {\n    #[error(\"Duplicate order by expression found: {order_by_expression}\")]\n    DuplicateOrderByExpression {\n        order_by_expression: Qualified<OrderByExpressionIdentifier>,\n    },\n    #[error(\n        \"Cannot order by array relationship {relationship_name} in order by expression {order_by_expression}\"\n    )]\n    CannotOrderByAnArrayRelationship {\n        order_by_expression: Qualified<OrderByExpressionIdentifier>,\n        relationship_name: RelationshipName,\n    },\n    #[error(\n        \"The orderable field \\\"{field_name}\\\" has field arguments and cannot be used in order by expressions.\"\n    )]\n    OrderByFieldWithFieldArguments { field_name: FieldName },\n}\n\nimpl ShouldBeAnError for OrderByExpressionIssue {\n    fn should_be_an_error(&self, flags: &open_dds::flags::OpenDdFlags) -> bool {","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/order_by_expressions/types.rs#L89-L125","documentation":"Thrown when two order-by expressions in the metadata resolve to the same qualified OrderByExpressionIdentifier, i.e. the same order-by expression is defined more than once for a type. Identifiers must be unique within the metadata namespace.","triggerScenarios":"Defining two entries in order_by_expressions metadata with the same name/subgraph/type combination, or including the same expression file twice, causing duplicate Qualified<OrderByExpressionIdentifier> keys during resolution.","commonSituations":"Copy-pasting an order-by expression block and forgetting to rename it; merging metadata files that both define the same expression; YAML anchors/duplicates silently producing two identical entries.","solutions":["Search all order_by_expressions definitions for the identifier shown in the error","Delete or rename the duplicate so each identifier is defined exactly once","If merging files/subgraphs, ensure expression names are unique per subgraph"],"exampleFix":"# before\norder_by_expressions:\n  - name: authorByName\n    ...\n  - name: authorByName   # duplicate\n# after\norder_by_expressions:\n  - name: authorByName\n    ...\n  - name: authorByEmail\n    ...","handlingStrategy":"validation","validationCode":"const seen = new Set();\nfor (const e of order_by_expressions) {\n  const key = `${e.subgraph}::${e.name}`;\n  if (seen.has(key)) throw new Error(`duplicate ${key}`);\n  seen.add(key);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a uniqueness lint for order-by expression names in CI","Avoid duplicating metadata files in builds"],"tags":["metadata","duplicate","order-by","open-dds","validation"],"backgroundTag":"duplicate-metadata-definition","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}