ember-cli / ember-cli/ember-exam
validateLoadBalance crashes with TypeError when ember-cli version uses pnpm catalog syntax
- Dominant language
- JavaScript
- Stars
- 289
- Forks
- 65
- Avg merge
- 4m
- Merged PRs (30d)
- 9
Description
When a project uses [pnpm catalogs](https://pnpm.io/catalogs), `ember-cli` in `package.json` may have a value like `"catalog:tools"` rather than a semver string. `validateLoadBalance` reads this value directly and passes it to `semver.validRange()`, which returns `null` for non-semver strings. The subsequent `semver.gtr('3.2.0', null)` call then throws:
```
TypeError: Cannot read properties of null (reading 'trim')
at new Range (semver/classes/range.js:36:22)
at outside (semver/ranges/outside.js:15:11)
at Object.gtr (semver/ranges/gtr.js:5:42)
at TestsOptionsValidator.validateLoadBalance (ember-exam/lib/utils/tests-options-validator.js:296:16)
```
**Root cause** (`commands/exam.js:112`):
```js
this.emberCliVersion =
this.project.pkg.devDependencies['ember-cli'] ||
this.project.pkg.dependencies['ember-cli'];
```
This gives `"catalog:tools"` instead of a resolved version.
**Suggested fix:** Guard against non-semver strings before calling `semver.validRange`:
```js
const rawVersion = this.project.pkg.devDependencies['ember-cli'] ||
this.project.pkg.dependencies['ember-cli'];
// Catalog refs (e.g. "catalog:tools") are not semver — skip the check
this.emberCliVersion = semver.validRange(rawVersion) ? rawVersion : null;
```
Then in `validateLoadBalance`, treat a null version as "unknown / assumed sufficient" and skip the check rather than crashing. (The version being checked is 3.2.0 — any modern ember-cli satisfies this unconditionally.)
**Workaround:** Keep `ember-cli` pinned with an explicit version string in `package.json` rather than using a catalog ref.
**ember-exam version:** 10.1.0
---
*Issue written by Claude (claude-sonnet-4-6), approved by Peter Wagenet.*
Contributor guide
Assessment
This issue has not been assessed yet.