{"record":{"id":"e617ecccd0283081","repo":"hasura/graphql-engine","slug":"the-string-str-in-the-provided-json-value-is-not","errorCode":null,"errorMessage":"the string {str} in the provided json value is not a valid GraphQL name","messagePattern":"the string (.+?) in the provided json value is not a valid GraphQL name","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/lang-graphql/src/validation/error.rs","lineNumber":73,"sourceCode":"        alias: ast::Alias,\n        field1: ast::Name,\n        field2: ast::Name,\n    },\n    #[error(\n        \"fields of different type {type1} and {type2} cannot be merged under the same alias: {alias}\"\n    )]\n    FieldsConflictDifferingTypes {\n        alias: ast::Alias,\n        type1: ast::Type,\n        type2: ast::Type,\n    },\n    #[error(\"cannot merge fields with different arguments on the same alias: {alias}\")]\n    FieldsConflictDifferingArguments {\n        alias: ast::Alias,\n        location1: Option<spanning::SourcePosition>,\n        location2: Option<spanning::SourcePosition>,\n    },\n    #[error(\"the string {str} in the provided json value is not a valid GraphQL name\")]\n    NotAValidName { str: String },\n    #[error(\"expected a value of type {expected_type} but found a value of type {actual_type}\")]\n    IncorrectFormat {\n        expected_type: &'static str,\n        actual_type: &'static str,\n    },\n    #[error(\"a null value found when expected a value of not nullable type: {expected_type}\")]\n    UnexpectedNull { expected_type: ast::Type },\n    #[error(\"the field {field_name} on type {type_name} is not found\")]\n    InputFieldNotFound {\n        type_name: ast::TypeName,\n        field_name: ast::Name,\n    },\n    #[error(\"the required fields {} on type {type_name} are not found\", field_names.iter().fold(String::new(), |acc, name| acc + &name.to_string()))]\n    RequiredInputFieldsNotFound {\n        type_name: ast::TypeName,\n        field_names: Vec<ast::Name>,\n    },","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/lang-graphql/src/validation/error.rs#L55-L91","documentation":"Thrown when converting a JSON value (e.g. serde_json Value) into GraphQL variables/inputs and a string that must be a valid GraphQL name (`/^[_A-Za-z][_0-9A-Za-z]*$/`) fails that grammar — for example an enum value name or directive/field name coming from untrusted JSON. The error carries the offending string so you can see exactly which name is malformed.","triggerScenarios":"Passing JSON-derived enum variant names containing spaces, dashes, or starting with a digit (e.g. \"in-review\"); constructing dynamic queries/variable values from user input where a name-like string is embedded; deserializing IDs or labels into name positions.","commonSituations":"Accepting enum values or names from an API/frontend payload and forwarding them into a GraphQL request without sanitization; name grammars differing between systems (kebab-case backend enums vs camelCase GraphQL names); migration scripts feeding legacy identifiers as names.","solutions":["Validate/normalize the string to the GraphQL name grammar before conversion: start with a letter or underscore, then letters/digits/underscores only","Map kebab-case or spaced backend values to camelCase GraphQL enum names with an explicit conversion table","Reject or sanitize untrusted input rather than passing raw JSON strings into name positions"],"exampleFix":"// before\nlet name = json_str; // \"in-review\"\n// after\nfn to_graphql_name(s: &str) -> String { s.chars().map(|c| if c.is_alphanumeric() || c == '_' { c } else { '_' }).collect() }","handlingStrategy":"type-guard","validationCode":"fn is_graphql_name(s: &str) -> bool { let mut c = s.chars(); match c.next() { Some(h) if h == '_' || h.is_ascii_alphabetic() => c.all(|ch| ch == '_' || ch.is_ascii_alphanumeric()), _ => false } }","typeGuard":"fn is_graphql_name(s: &str) -> bool { !s.is_empty() && s.bytes().enumerate().all(|(i, b)| b == b'_' || b.is_ascii_alphabetic() || (i > 0 && b.is_ascii_digit())) }","tryCatchPattern":"match value_to_input(&json) { Err(Error::NotAValidName { str }) => sanitize_or_reject(&str), r => r }","preventionTips":["Validate name-like strings against /^[_A-Za-z][_0-9A-Za-z]*$/ before conversion","Maintain an explicit mapping table from backend enum spellings to GraphQL names","Never forward raw user input into GraphQL name positions"],"tags":["graphql","name-validation","json","input-coercion"],"backgroundTag":"invalid-graphql-name","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}