Solvedwp calypso Calypso: Deep links redirecting

Steps to reproduce

  1. Find a site-specific address within Calypso. For example, I found by going to: My Sites > Domains on my site
  2. Copy this address and paste it in to a new browser tab
  3. In one case we found that this deep link would instead redirect us to the site's stats page:
  4. In other cases when we visit these types of addresses we're directed to another page that requires us to confirm which website we're editing:
    screen shot 2018-11-06 at 2 07 06 pm

What I expected

To be taken to the page that this address specifically links to.

What happened instead

Instead I am redirected to my stats page or directed to choose which website I'm working on first (which should not be asked when the domain is specified in the deep link address).

Context / Source

This was initially a #user-report. I was able to replicate the behavior through their account (where we were redirected to the stats page) and also on my own account (where I was redirected to choose my website, per the screenshot).


15 Answers

✔️Accepted Answer

This is a real bug and it's probably been around for some time. Not a recent regression.

Easy to reproduce if you clear your local Indexed DB storage and then go to a site-specific domain URL: /domains/manage/ Instead of displaying domains for, you will be redirected to:

  • /domains/manage (with site selection list) for multi-site users
  • /stats for single-site users

It's caused by the redirectIfNoSite handler that interacts in a buggy way with the siteSelection handler.

When no Redux state is cached in local storage, Calypso doesn't have data for the site on initial load. It doesn't even know the site ID. It knows only the slug from the URL.

That's why the siteSelection handler initially sets the state.ui.selectedSiteId to null and starts to fetch the site data. Then, after the site data are fetched, sets the selected site ID to the correct value and the UI is rerendered with the new prop.

But redirectIfNoSite will redirect too soon -- at a time when the selected site ID is still null.

The redirectIfNoSite handler shouldn't be there at all -- it just duplicates work that siteSelection already does: redirect to /domains/manage if the site doesn't exist, handle edge cases for single-site users...

If we remove it though, the Domains handlers that render UI will need to cope with selectedSiteId being null. I'm not sure if they can do that.

See also: #23969 by @spen from April 2018 -- that might be the moment when the bug was introduced.

Related Issues:

wp calypso Editor: Permission Errors when trying to Update/Publish Post/Pages
The fix has been deployed today to wpcom as D57128 after the first attempt had to be reverted due to...
wp calypso Calypso: Deep links redirecting
This is a real bug and it's probably been around for some time Not a recent regression ...
webpack Cannot assign to read only property 'exports' of object '#<Object>' (mix require and export)
The code above is ok You can mix require and export You can't mix import and module.exports. ...
webpack How to exclude node_modules but one
@borm: a solution: Subj as example I create some module in another folder ( /projects/MY_MODULE ) MY...
babel ReferenceError regeneratorRuntime is not defined
I had this issue using rollup with babel I just used this babel config to resolve it : ...
webpack nodejs 17: digital envelope routines::unsupported
workaround: Bug report What is the current behavior? Other relevant information: webpack version: 5....
webpack TypeError: Data must be a string or a buffer
Here is a workaround to help you to find the wrong import Using the latest 2.2.0 release although th...
javascript How to configure React Native (Expo) project to use AirBnB's React rules via ESLint?
This is what I do in React and React Native: Step 1 Step 2 Backup your eslintrc file in case you wan...
webpack webpack 4: access the mode flag from webpack.config.js file
This seems to work correctly with --mode production -p and <no flag> Do you want to request a featur...
webpack Webpack gives $ is not defined or jQuery is not defined error in console
Just use like this or add to webpack Do you want to request a feature or report a bug? What is the c...
babel Support for the experimental syntax 'classProperties' isn't currently enabled
@xtuc Actually I tried to erase bable preset & plugins code in package.json and webpack.config.js an...
webpack Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
I got this same error reinstalled it locally and ran it with package scripts and it worked npm remov...
core js 3.0.0-beta.3 - Can't resolve 'core-js/es7/reflect'
I have the Angular 7 CLI working fine with core-js 3 I'm using @angular/cli I upgraded to the 3.0.0-...
webpack "Uncaught SyntaxError: Unexpected token <" error happened sometimes
I have a same problem fix with added <base href=/ /> into the <head> of my index.html ...
babel No "exports" main resolved in @babel/helper-compilation-targets/package.json
I fixed this issue by removing the node_modules directory and package-lock.json file then run npm in...
babel Module build failed (from ./node_modules/babel-loader/lib/index.js):
The issue might be because babel-loader@8 depends on babel@7? If you want to use babel-loader@8 try ...
webpack [BUG?] npm link causes Webpack to look for babel-plugin in linked package node_modules.
try to add resolve: { symlinks: false } to your webpack.config I've linked a package that is outside...
webpack Parsing of import() fails in 4.29.0 (Compilation issue, related to dynamic import)
Running these commands fixes the problem in your repro @Dbuggerx It seem to be a npm problem ...
webpack webpack watch mode not working....
Try this workaround: Add this to your webpack configuration file: General Information: webpack versi...
babel "regeneratorRuntime is not defined" error with async and "useBuiltIns": "usage"
The solution from this issue thread worked for me Importing the following: for my dependencies and h...
javascript Using 'ForInStatement' is not allowed (no-restricted-syntax)
@francoisromain Object.assign(options opts) Since version 8 there is this error on for in loops What...
webpack webpack broken by ajv@6.9.0, "custom keyword definition is invalid: data.errors should be boolean"
If you use yarn add below to package.json then run yarn install if you use npm ...
babel Plugin/Preset files are not allowed to export objects, only functions.
Just like env is now @babel/env react should be @babel/react and you'll need to install @babel/prese...
webpack Webpack 2.0 doesn't support custom command line arguments?
Yes this is intended Custom argumens can be passed via --env prefix i e --env.compress ...
webpack error:'output.filename' is required, either in config file or as --output-filename"
exports not export,that is the reason. Do you want to request a feature or report a bug? bug What is...
javascript Why no setState in componentDidMount?
As the docs state that they belong in componentDidMount: If you want to integrate with other JavaScr...
webpack DefinePlugin does not inject variable
Hmm I was just having this issue and it was trolling me process.env was showing as an empty object ...
webpack Webpack moment.js integration
To the next person trying to get one of the above configurations to work (which they did not for me)...
webpack Strange warning stating that export does not exist when it does
Maybe this is not a bug Bug report What is the current behavior? Not sure if this is a problem with ...
javascript .jsx extension cannot be used with React Native
@borisyankov what's common isn't the primary motivator for this guide it's what we use at Airbnb We ...
babel Requires Babel “7.0.0-0” but was loaded with “6.26.3”
@rayj10 I think you need to add babel-core: ^7.0.0-bridge.0 Try this: Bug Report Current Behavior Ke...
webpack multiple usage of the CommonsChunkPlugin, only first works
The CommonsChunkPlugin selects only entry chunks Do you want to request a feature or report a bug? I...
webpack Using dynamic require on node targets WITHOUT resolve or bundle the target module
const server = __non_webpack_require__(entryPath) Do you want to request a feature or report a bug? ...
webpack Webpack 4 chunking different runtime behaviour compared to Webpack 3
I stumbled upon such a configuration after trying many many variations Conceptually I'm not 100% sur...
javascript What is the benefit of prefer-default-export?
webpack Error when trying to build bundle after upgrading to 4.20.0
Please read CHANGELOG Update internal struct...
webpack Using webpack 4 on a large project (or, how to avoid "JavaScript heap out of memory" with production mode)
For those looking to increase the memory used by webpack Do you want to request a feature or report ...
webpack Webpack 4.0 file-loader json issue
I was able to copy my .json config file to the build folder using this: Do you want to request a fea...
babel Async functions producing an error "ReferenceError: regeneratorRuntime is not defined"
Update your .babelrc file according to the following examples it will work Input Code Babel Configur...
webpack Module not found: Error: Cannot resolve 'file' or 'directory' (import sass with a relative font folder in webpack)
Just had this problem too It's an error in finding the right directory Use the path relative to / In...
babel Migrate to babel 7: Requires Babel "^7.0.0-0", but was loaded with "6.26.3"
@budarin try installing babel-core@7.0.0-bridge.0 alongside @babel/core and then adding this to your...
javascript What is the point of the no-continue rule?
@MegaArman Loops are still useful in 2018 in many non trivial cases and will stay useful even in 211...
webpack import() support in webpack 2
import() reached stage-3 🎉 Domenic's import() proposal is as of last week stage-2 ...
webpack [NodeJS v.7] Webpack ERROR in Path must be a string. Received undefined
add a key 'publicPath' to the webpack config output node I'm update my node.js to version 7 ...
webpack BUG: "export 'default' (imported as 'selection_enter') was not found in './enter'
In case anyone stumbles across this thread.. Do you want to request a feature or report a bug? BUG W...
javascript Option to disable a11y plugin?
For everyone who wondering how to use mentioned workaround: We love the airbnb style guide including...
webpack Ability to export only module's default when building a library
Is seems this issue was solved by the libraryExport setting and should be closed. ...
webpack Error: Cannot find module 'webpack/lib/removeAndDo' when building a project
For me the issue was caused by extract-text-webpack-plugin module Older version of this package are ...
babel copy-files flag does not respect ignore block in .babelrc
Forgive me if I'm coming out of left field but.. Bug: If in your build script you have --copy-files ...
javascript react/jsx-no-bind: how to pass args from callbacks?
Right - at that point you might as well disable the rule. I have a question about react/jsx-no-bind ...