Solvedwp calypso Calypso: Deep links redirecting

Steps to reproduce

  1. Find a site-specific address within Calypso. For example, I found https://wordpress.com/domains/manage/lillylearns.com by going to: My Sites > Domains on my lillylearns.com 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: https://wordpress.com/stats/day/131376930
  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).

7072782-hc

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/site.blog. Instead of displaying domains for site.blog, 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 site.blog on initial load. It doesn't even know the site ID. It knows only the site.blog 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:

15
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...
4
wp calypso Calypso: Deep links redirecting
This is a real bug and it's probably been around for some time Not a recent regression ...
811
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. ...
727
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...
499
babel ReferenceError regeneratorRuntime is not defined
I had this issue using rollup with babel I just used this babel config to resolve it : ...
488
webpack nodejs 17: digital envelope routines::unsupported
workaround: Bug report What is the current behavior? Other relevant information: webpack version: 5....
473
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...
391
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...
296
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...
284
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...
279
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...
233
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...
224
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-...
216
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 ...
206
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...
187
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 ...
180
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...
177
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 ...
166
webpack webpack watch mode not working....
Try this workaround: Add this to your webpack configuration file: General Information: webpack versi...
155
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...
139
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...
122
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 ...
113
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...
106
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 ...
103
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...
95
javascript Why no setState in componentDidMount?
As the docs state that they belong in componentDidMount: If you want to integrate with other JavaScr...
94
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 ...
83
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)...
82
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 ...
71
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 ...
71
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...
69
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...
67
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? ...
64
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...
63
javascript What is the benefit of prefer-default-export?
https://blog.neufund.org/why-we-have-banned-default-exports-and-you-should-do-the-same-d51fdc2cf2ad?...
63
webpack Error when trying to build bundle after upgrading to 4.20.0
Please read CHANGELOG https://github.com/webpack/webpack/releases/tag/v4.20.0 Update internal struct...
60
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 ...
60
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...
56
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...
56
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...
55
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...
49
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...
49
webpack import() support in webpack 2
import() reached stage-3 🎉 Domenic's import() proposal is as of last week stage-2 ...
49
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 ...
49
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...
48
javascript Option to disable a11y plugin?
For everyone who wondering how to use mentioned workaround: We love the airbnb style guide including...
48
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. ...
48
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 ...
46
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 ...
45
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 ...