[Bug] Transition to same route without parameters creates error `Uncaught TypeError: routeInfos[(routeInfoLength - 1)] is undefined` when a `queryParam` has default value `null`
- Dominant language
- TypeScript
- Stars
- 22.6k
- Forks
- 4.2k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 15
Description
### 🐞 Describe the Bug
When adding a `transitionTo` on higher router we get error `Uncaught TypeError: routeInfos[(routeInfoLength - 1)] is undefined`.
The error occures, when the default value from queryParameter is `null`.

### 🔬 Minimal Reproduction
Example repo: https://github.com/mkszepp/ember-transition-bug
Create a new app with route named `base` and copy this code parts.
```js
// routes/application.js
import Route from '@ember/routing/route';
import { service } from '@ember/service';
export default class ApplicationRoute extends Route {
@service router;
redirect() {
super.redirect(...arguments);
this.router.transitionTo('base');
}
}
```
```js
// controllers/base.js
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
export default class BaseController extends Controller {
@tracked messageType = null;
queryParams = ['messageType'];
}
```
1. Run ember s
2. Page is loading and will be auto redirected to sub route "base" (no error)
3. Refresh page (F5)
4. Error Uncaught TypeError: routeInfos[(routeInfoLength - 1)] is undefined
It seems like router has problem with default value `null`, when the current route is the same.
### 🌍 Environment
- Ember: `v5.8.0` (its also present in older versions)
- Node.js/npm: `v18.19`
### ➕ Additional Context
There is reported the same error in other cases with older versions.
https://github.com/emberjs/ember.js/issues?q=is%3Aissue+is%3Aopen+routeInfos%5B%28routeInfoLength+-+1%29%5D
Contributor guide
Assessment
This issue has not been assessed yet.