Foundry376/Mailspring · error

Expected string token to begin with double quote (")

Error message

Expected string token to begin with double quote (")

What it means

Internal parser invariant in nextStringToken (search-query-parser): the function was called on input not starting with a double quote. nextToken should only route quoted-string parsing here after seeing a '"', so this indicates a tokenizer bug rather than bad user input.

Source

Thrown at app/src/services/search/search-query-parser.ts:21

  OrQueryExpression,
  NotQueryExpression,
  AndQueryExpression,
  FromQueryExpression,
  ToQueryExpression,
  SubjectQueryExpression,
  GenericQueryExpression,
  TextQueryExpression,
  UnreadStatusQueryExpression,
  StarredStatusQueryExpression,
  DateQueryExpression,
  InQueryExpression,
  HasAttachmentQueryExpression,
  QueryExpression,
} from './search-query-ast';

const nextStringToken = (text: string): [SearchQueryToken, string] => {
  if (text[0] !== '"') {
    throw new Error('Expected string token to begin with double quote (")');
  }
  if (text.length < 2) {
    throw new Error('Expected string but ran out of input');
  }
  let pos = 1;
  while (pos < text.length) {
    const c = text[pos];
    if (c === '"') {
      return [new SearchQueryToken(text.substring(1, pos)), text.substring(pos + 1)];
    }
    pos += 1;
  }
  throw new Error('Expected string but ran out of input');
};

const isWhitespace = (c) => {
  switch (c) {
    case ' ':

View on GitHub (pinned to 648c685d60)

Solutions

  1. Report the query text that triggered it as a search-parser bug
  2. Simplify the search query (remove unbalanced quotes/operators) as a workaround
  3. Reproduce with the failing query string in the search test specs
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at app/src/services/search/search-query-parser.ts:21 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Foundry376/Mailspring@648c685d60 (2026-09-03). Data as JSON: /api/errors/e70e9db3567bb38f. Report an issue: GitHub.