hasura/graphql-engine · error · Error

expected a \" but found: {0:?}

Error message

expected a \" but found: {0:?}

What it means

String lexer error: expected an opening double-quote to start a string literal but found a different byte (or None at end of input). Raised by the string scanner when a string start sequence is required but absent.

Source

Thrown at v3/crates/graphql/lang-graphql/src/lexer/string.rs:7

use std::cmp::min;
use std::str::from_utf8_unchecked;
use thiserror::Error;

#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum Error {
    #[error("expected a \" but found: {0:?}")]
    StartingSequenceNotFound(Option<u8>),

    /// An unterminated string literal was found
    ///
    /// Apart from forgetting the ending `"`, terminating a string within a
    /// Unicode escape sequence or having a line break in the string also
    /// causes this error.
    #[error("string is unterminated")]
    Unterminated,

    /// An unknown character in a string literal was found
    ///
    /// This occurs when an invalid source character is found in a string
    /// literal, such as ASCII control characters.
    #[error("unexpected character in string: {0:?}")]
    UnknownCharacterInString(char),

    /// An unknown escape sequence in a string literal was found

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Quote the string literal in the query
  2. Use GraphQL variables for string values
  3. Check for truncation of the request body (Content-Length issues, proxy cut-offs)

Example fix

# before
query { songs(where: {title: {_eq: hey}}) }
# after
query { songs(where: {title: {_eq: "hey"}}) }
Defensive patterns

Strategy: validation

Validate before calling

// Ensure every inline string argument starts with a quote
// e.g. lint: /:\s*[^\s"\[\{\$]/ after an argument colon

Try / catch

// Catch the lexer error, reprint the query region around the offset, and quote the literal

Prevention

When it happens

Trigger: Query text where a string is expected but the quote is missing, e.g. argument value typed as a bare word where a string was required; truncated input ending right before a string.

Common situations: Hand-written queries with missing quotes; templating bugs stripping quotes; truncated request bodies.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/9cc423867443b202. Report an issue: GitHub.