cypress-io/cypress · warning · Error
name should be a single string but got: ${from.query.name}
Error message
name should be a single string but got: ${from.query.name} What it means
Thrown by the /redirect route handler in the Cypress app router. The route reads query.name and requires it to be a single string. Express/Vue Router parse repeated query params (?name=A&name=B) into an array, which fails the typeof === 'string' guard. This is a defensive validation on an internal redirect used by changeUrlToDebug in the server.
Source
Thrown at packages/app/src/router/router.ts:42
/**
* Redirect route useful for passing page params when routing to a particular page
*
* @param name route name
* @param params url encoded JSON object of page component params
*
* @example
* // redirects to the Debug page passing a parameter of `from` set to `notification`
* "/redirect?name=Debug¶ms=%7B%22from%22%3A%22notification%22%7D"
*
* @see changeUrlToDebug in packages/server/lib/open_project.ts
*/
routes.push({
path: '/redirect',
redirect: (from) => {
if (from.query.name) {
if (typeof from.query.name !== 'string') {
throw new Error(`name should be a single string but got: ${from.query.name}`)
}
let params = {}
if (from.query.params) {
if (typeof from.query.params !== 'string') {
throw new Error(`params should be a string but got: ${from.query.params}`)
}
try {
params = JSON.parse(from.query.params)
} catch {
throw new Error(`params was not valid JSON: ${from.query.params}`)
}
}
return {
name: from.query.name,View on GitHub (pinned to 0d85fdc912)
Solutions
- If you construct the URL, ensure `name` appears exactly once: `/redirect?name=Debug`.
- When serializing params from JS, use URLSearchParams with set (not append) for `name`.
- Report a Cypress bug if you hit this from normal app navigation — the server should not be emitting duplicate name params.
Example fix
// before
const url = `/redirect?name=Debug&name=${secondary}`
// after
const params = new URLSearchParams()
params.set('name', 'Debug')
params.set('params', JSON.stringify({ from: secondary }))
const url = `/redirect?${params.toString()}` Defensive patterns
Strategy: validation
Validate before calling
function singleString (v: unknown): string | null {
return typeof v === 'string' ? v : null
}
const name = singleString(from.query.name)
if (!name) throw new Error('name must be a single string') Type guard
function isSingleString (v: unknown): v is string {
return typeof v === 'string'
} Prevention
- Use URLSearchParams.set (not append) for the name param.
- URL-encode the redirect link before navigating.
- Test redirect URLs in CI smoke checks.
When it happens
Trigger: A client (the server's open_project.ts changeUrlToDebug, or a hand-crafted URL) issues /redirect?name=Debug&name=Runs causing Express to surface name as ['Debug','Runs']. Also reproducible if a buggy caller appends name twice.
Common situations: Internal Cypress URL-construction bug that double-appends name, browser extension or proxy mangling query strings, or third-party code linking to /redirect with duplicate params.
Related errors
- params should be a string but got: ${from.query.params}
- params was not valid JSON: ${from.query.params}
- Missing event for ${event}
AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12).
Data as JSON: /api/errors/05fd01c6619fdff3.
Report an issue: GitHub.