hasura/graphql-engine · error · Error

end of file reached when expecting further input

Error message

end of file reached when expecting further input

What it means

The lexer hit end of input while a partially scanned token still requires more characters, e.g. scanning "1." — after the dot a digit must follow but the source ended.

Source

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

    line: usize,
    column: usize,
}

/// Error when tokenizing the input source
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum Error {
    /// An unexpected character was found
    ///
    /// Unexpected characters are characters that _do_ exist in the GraphQL
    /// language, but is not expected at the current position in the document.
    #[error("unexpected character in the document: {0:?}")]
    UnexpectedCharacter(char),

    /// The input source was unexpectedly terminated
    ///
    /// Emitted when the current token requires a succeeding character, but
    /// the source has reached EOF. Emitted when scanning e.g. `"1."`.
    #[error("end of file reached when expecting further input")]
    UnexpectedEndOfFile,

    /// An invalid string literal was found
    #[error("invalid string literal found: {0:?}")]
    InvalidString(string::Error),

    /// An invalid number literal was found
    #[error("invalid number literal found: {0:?}")]
    InvalidNumber(number::Error),

    // An invalid graphql name
    #[error("invalid graphql name: {0}")]
    InvalidGraphQlName(String),
}

impl From<ast::common::InvalidGraphQlName> for Error {
    fn from(error: ast::common::InvalidGraphQlName) -> Self {
        Error::InvalidGraphQlName(error.0)

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Check for truncated input at the reported offset (often the very end of the document)
  2. Add the missing trailing characters (e.g. the fractional/exponent digits)
  3. If reading from a stream, ensure the full payload is buffered before parsing

Example fix

# before
query { price(cost: 1.) }   # ends right after '.'
# after
query { price(cost: 1.0) }
Defensive patterns

Strategy: validation

Validate before calling

if src.ends_with(|c: char| c.is_ascii_digit() || c == '.' || c == '-') {
    // possibly truncated number token; verify it ends in a complete token
}

Try / catch

On UnexpectedEndOfFile, check whether the document was truncated in transit (content-length, checksum) before retrying the parse.

Prevention

When it happens

Trigger: Lexing a document that ends mid-token: "1." at EOF, an unterminated number exponent like "1e", or a token whose continuation character is missing at the boundary of the input.

Common situations: Truncated queries from HTTP transport or file reads, substring slicing of larger documents, or tests with incomplete fixtures.

Related errors


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