{"record":{"id":"281382993c37a59e","repo":"hasura/graphql-engine","slug":"error-in-order-by-expression-order-by-expression-281382","errorCode":null,"errorMessage":"Error in order by expression {order_by_expression_name}: {error}","messagePattern":"Error in order by expression (.+?): (.+?)","errorType":"validation","errorClass":"NamedOrderByExpressionError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/order_by_expressions/error.rs","lineNumber":12,"sourceCode":"use crate::stages::graphql_config;\nuse crate::types::error::ContextualError;\nuse crate::types::subgraph::{Qualified, QualifiedBaseType};\n\nuse open_dds::{\n    order_by_expression::OrderByExpressionName,\n    relationships::RelationshipName,\n    types::{CustomTypeName, FieldName, TypeName},\n};\n\n#[derive(Debug, thiserror::Error)]\n#[error(\"Error in order by expression {order_by_expression_name}: {error}\")]\npub struct NamedOrderByExpressionError {\n    pub order_by_expression_name: Qualified<OrderByExpressionName>,\n    pub error: OrderByExpressionError,\n}\n\nimpl ContextualError for NamedOrderByExpressionError {\n    fn create_error_context(&self) -> Option<error_context::Context> {\n        None\n    }\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum OrderByExpressionError {\n    #[error(\"unknown field {field_name} in orderable fields\")]\n    UnknownFieldInOrderByExpression { field_name: FieldName },\n    #[error(\"The data type {data_type} has not been defined\")]\n    UnknownOrderableType {\n        data_type: Qualified<CustomTypeName>,","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/order_by_expressions/error.rs#L1-L30","documentation":"Wrapper error attaching the name of the order-by expression to an underlying OrderByExpressionError. The message shows which named order_by_expression failed and the inner error describing the specific problem in its definition.","triggerScenarios":"Resolving a named order-by expression (e.g. one referenced by an orderable field) whose body is invalid — unknown field, unknown relationship, undefined type, or graphql config problems bubble up here.","commonSituations":"An order_by_expression defined in metadata references fields or relationships that do not exist or were renamed; the expression's type disagrees with field types.","solutions":["Look at the inner error text after the colon to identify the concrete failure in the named expression","Fix the expression definition (field names, relationships, types) in metadata","If referenced entities were renamed, update the expression or delete it and recreate it"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate every named expression resolves against the current schema before apply\nfor (const [name, expr] of Object.entries(orderByExpressions)) {\n  if (!expressionResolves(expr, objectTypes, relationships)) throw new Error(`Invalid order-by expression ${name}`);\n}","typeGuard":null,"tryCatchPattern":"// Catch and unwrap the named wrapper to log which expression failed\ntry { await applyMetadata(md); }\ncatch (e) { if (String(e).startsWith('Error in order by expression')) console.error(e); throw e; }","preventionTips":["Lint order-by expressions whenever fields or relationships change","Delete unused expressions during cleanup"],"tags":["hasura","metadata","order-by","expressions","contextual-error"],"backgroundTag":"order-by-expression-invalid","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}