vuejs/vue-router · warning

${e.message}

Error message

${e.message}

What it means

resolveQuery delegates to parseQuery (default or a custom _parseQuery) inside a try/catch. If the parser throws on the raw query string, the error's message is surfaced via this warning and an empty parsed query ({}) is used so navigation can proceed. This is a dev-mode safety net around malformed query strings or a broken custom parser.

Source

Thrown at src/util/query.js:38

  } catch (err) {
    if (process.env.NODE_ENV !== 'production') {
      warn(false, `Error decoding "${str}". Leaving it intact.`)
    }
  }
  return str
}

export function resolveQuery (
  query: ?string,
  extraQuery: Dictionary<string> = {},
  _parseQuery: ?Function
): Dictionary<string> {
  const parse = _parseQuery || parseQuery
  let parsedQuery
  try {
    parsedQuery = parse(query || '')
  } catch (e) {
    process.env.NODE_ENV !== 'production' && warn(false, e.message)
    parsedQuery = {}
  }
  for (const key in extraQuery) {
    const value = extraQuery[key]
    parsedQuery[key] = Array.isArray(value)
      ? value.map(castQueryParamValue)
      : castQueryParamValue(value)
  }
  return parsedQuery
}

const castQueryParamValue = value => (value == null || typeof value === 'object' ? value : String(value))

function parseQuery (query: string): Dictionary<string> {
  const res = {}

  query = query.trim().replace(/^(\?|#|&)/, '')

View on GitHub (pinned to 680ccc68c5)

Solutions

  1. Fix the malformed query string at the source (properly URL-encode values with encodeURIComponent / URLSearchParams).
  2. Make the custom _parseQuery never throw: wrap its internals in try/catch and return a partial/partial object instead.
  3. Validate/sanitize location.query strings before passing them to router.push/resolve.
  4. Upgrade vue-router if the throwing parser was a known fixed bug; otherwise add an integration test for the offending input.

Example fix

// before
function _parseQuery (query) { return strictParse(query) } // may throw
// after
function _parseQuery (query) {
  try { return strictParse(query) } catch (e) { return {} }
}
Defensive patterns

Strategy: try-catch

Validate before calling

function safeQuery (raw) {
  try { return new URLSearchParams(raw.startsWith('?') ? raw.slice(1) : raw).toString() } catch (e) { return '' }
}

Try / catch

try {
  await router.push({ path: '/x', query: parsedQuery })
} catch (e) {
  console.warn('query parsing failed:', e.message)
  await router.push({ path: '/x' })
}

Prevention

When it happens

Trigger: Parsing a query string that makes parseQuery throw — in the default parser this typically happens when decode throws on invalid percent-encoding that propagates (custom parsers may throw for any reason), or supplying a faulty _parseQuery implementation to routes/resolveQuery that raises on edge-case input.

Common situations: Custom parseQuery replacements (used for query param serialization customization) that throw on unusual input like 'a=%' or keys without '='; malformed URLs from external sources; library upgrades where a custom parser's assumptions no longer hold.

Related errors


AI-assisted analysis of vuejs/vue-router@680ccc68c5 (2026-09-02). Data as JSON: /api/errors/2cd23769d79d594c. Report an issue: GitHub.