{"record":{"id":"265396ad723e5233","repo":"hasura/graphql-engine","slug":"alias-is-not-a-valid-alias","errorCode":null,"errorMessage":"'{alias:} is not a valid alias","messagePattern":"'(.+?) is not a valid alias","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/ir/src/error.rs","lineNumber":55,"sourceCode":"#[transitive(from(InternalEngineError, InternalError))]\n#[transitive(from(InternalDeveloperError, InternalError))]\npub enum Error {\n    #[error(\"The global ID {encoded_value:} couldn't be decoded due to {decoding_error:}\")]\n    FailureDecodingGlobalId {\n        encoded_value: String,\n        decoding_error: String,\n    },\n\n    #[error(\"Unexpected value: expecting {expected_kind:}, but found: {found:}\")]\n    UnexpectedValue {\n        expected_kind: &'static str,\n        found: json::Value,\n    },\n\n    #[error(\"'{name:}' is not a valid GraphQL name.\")]\n    TypeFieldInvalidGraphQlName { name: String },\n\n    #[error(\"'{alias:} is not a valid alias\")]\n    InvalidAlias { alias: String },\n\n    #[error(\"{value} is not a valid limit value\")]\n    InvalidLimitValue { value: u32 },\n\n    #[error(\"{value} is not a valid offset value\")]\n    InvalidOffsetValue { value: u32 },\n\n    #[error(\"field '{field_name:} not found in entity representation\")]\n    FieldNotFoundInEntityRepresentation { field_name: FieldName },\n\n    #[error(\n        \"order_by expects a list of input objects with exactly one key-value pair per input object. Please split the input object with multiple key-value pairs into a list of single key-value pair objects.\"\n    )]\n    OrderByObjectShouldExactlyHaveOneKeyValuePair,\n\n    #[error(\"missing non-nullable argument {argument_name:} for field {field_name:}\")]\n    MissingNonNullableArgument {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/ir/src/error.rs#L37-L73","documentation":"Field aliases in GraphQL queries must themselves be valid GraphQL names. When the IR parser encounters an alias that fails GraphQL name validation, it throws this error naming the invalid alias. This is distinct from invalid type/field names (error 646) — it specifically covers the 'alias:' portion of a selection.","triggerScenarios":"A selection like { validField: \"bad alias\": value } — concretely, any alias containing invalid characters (dashes, spaces, leading digits) or a query built programmatically that interpolates unvalidated strings as aliases.","commonSituations":"Query builders or GraphQL generators producing aliases from arbitrary keys (e.g. hash strings with dashes, localized labels); templating queries with user text; porting queries from other DSLs.","solutions":["Change the alias to a valid GraphQL name (letters, digits, underscore; not starting with a digit)","If aliases are generated, sanitize keys through a name-safe transformation before building the query","Lint/validate generated queries before sending them (graphql validation tooling)"],"exampleFix":"# before\nquery {{ user {{ my-alias: name }} }}\n\n# after\nquery {{ user {{ myAlias: name }} }}","handlingStrategy":"validation","validationCode":"const NAME_RE = /^[_A-Za-z][_0-9A-Za-z]*$/;\nfunction safeAlias(key: string): string {{\n  return key.replace(/[^_0-9A-Za-z]/g, '_').replace(/^([0-9])/, '_$1');\n}}\nif (!NAME_RE.test(alias)) throw new TypeError(`Invalid alias: ${{alias}}`);","typeGuard":"function isValidAlias(alias: string): boolean {{\n  return /^[_A-Za-z][_0-9A-Za-z]*$/.test(alias);\n}}","tryCatchPattern":null,"preventionTips":["Run generated aliases through a name sanitizer before query construction","Lint built queries with a GraphQL parser before sending","Avoid using display labels or hash keys directly as aliases"],"tags":["graphql","alias","naming","validation","rust"],"backgroundTag":"invalid-graphql-alias","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}