{"record":{"id":"1a09aa3aecf233a1","repo":"vuejs/vue-router","slug":"invalid-redirect-option-json-stringify-redirect","errorCode":null,"errorMessage":"invalid redirect option: ${JSON.stringify(redirect)}","messagePattern":"invalid redirect option: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/create-matcher.js","lineNumber":112,"sourceCode":"    return _createRoute(null, location)\n  }\n\n  function redirect (\n    record: RouteRecord,\n    location: Location\n  ): Route {\n    const originalRedirect = record.redirect\n    let redirect = typeof originalRedirect === 'function'\n      ? originalRedirect(createRoute(record, location, null, router))\n      : originalRedirect\n\n    if (typeof redirect === 'string') {\n      redirect = { path: redirect }\n    }\n\n    if (!redirect || typeof redirect !== 'object') {\n      if (process.env.NODE_ENV !== 'production') {\n        warn(\n          false, `invalid redirect option: ${JSON.stringify(redirect)}`\n        )\n      }\n      return _createRoute(null, location)\n    }\n\n    const re: Object = redirect\n    const { name, path } = re\n    let { query, hash, params } = location\n    query = re.hasOwnProperty('query') ? re.query : query\n    hash = re.hasOwnProperty('hash') ? re.hash : hash\n    params = re.hasOwnProperty('params') ? re.params : params\n\n    if (name) {\n      // resolved named direct\n      const targetRecord = nameMap[name]\n      if (process.env.NODE_ENV !== 'production') {\n        assert(targetRecord, `redirect failed: named route \"${name}\" not found.`)","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/vuejs/vue-router/blob/680ccc68c506cca9be6207745043245d61fa715a/src/create-matcher.js#L94-L130","documentation":"vue-router emits this dev-mode warning when a route's `redirect` option is neither a string, an object with a `path`/`name`, nor a function. The matcher cannot build a redirect target from it, so it warns and falls back to creating an empty/non-matching route for the location.","triggerScenarios":"Passing redirect: null, undefined, a number, a boolean, or an empty value in a route record; e.g. { path: '/a', redirect: null } or reading redirect from config that is missing. Note: a falsy redirect that survived the earlier truthiness checks reaches this branch.","commonSituations":"Routes generated dynamically from API/config data where the redirect field is absent or of the wrong type; typos like redirect: '/path' vs redirect: {name}; JSON configs where redirect was dropped during serialization.","solutions":["Give redirect a valid value: a path string ('/b'), an object ({ path: '/b' } or { name: 'b' }), or a function returning one","Remove the redirect option entirely if no redirect is intended","If redirect comes from external config, validate its shape before building the route table","Log JSON.stringify(redirect) (as the warning does) to see the actual offending value"],"exampleFix":"// before\n{ path: '/old', redirect: null }\n// after\n{ path: '/old', redirect: '/new' }","handlingStrategy":"validation","validationCode":"function isValidRedirect(redirect) {\n  if (typeof redirect === 'string' && redirect.length > 0) return true\n  if (redirect && typeof redirect === 'object' && (redirect.path || redirect.name)) return true\n  return false\n}\n// before building routes: routes.forEach(r => { if ('redirect' in r && !isValidRedirect(r.redirect)) throw new Error('bad redirect on ' + r.path) })","typeGuard":"function isRedirectLocation(v) {\n  return typeof v === 'string' || (v !== null && typeof v === 'object' && (typeof v.path === 'string' || typeof v.name === 'string'))\n}","tryCatchPattern":null,"preventionTips":["Always give redirect a string, { path }, { name }, function, or false","Validate externally-sourced route configs before registering","Use TypeScript RouteConfig typing to catch malformed redirects at compile time"],"tags":["vue-router","routing","configuration","redirect"],"backgroundTag":"invalid-route-redirect-config","analyzedSha":"680ccc68c506cca9be6207745043245d61fa715a","analyzedAt":"2026-09-02T19:19:01.204Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}