Skip to content

validateLoadBalance crashes with TypeError when ember-cli version uses pnpm catalog syntax #1513

Description

@wagenet

When a project uses pnpm 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):

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:

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions