redis/node-redis · error · TypeError

${version} is not a valid redis version

Error message

${version} is not a valid redis version

What it means

TestUtils.parseVersionNumber throws a TypeError when the version string contains no substring matching the regex (^|-)\d+(\.\d+)*($|-) — i.e., there is no digit run delimited by string start, end, or a dash. The method parses the Redis docker image tag or an explicit --redis-version into comparable numeric components; 'latest' and 'edge' are special-cased to [Infinity] before this check.

Source

Thrown at packages/test-utils/lib/index.ts:222

> {
  client: ClientTestOptions<M, F, S, RESP, TYPE_MAPPING>;
  cluster: ClusterTestOptions<M, F, S, RESP, TYPE_MAPPING/*, POLICIES*/>;
}

interface Version {
  tag: string;
  numbers: Array<number>;
}

export default class TestUtils {
  static parseVersionNumber(version: string): Array<number> {
    if (version === 'latest' || version === 'edge') return [Infinity];


    // Match complete version number patterns
    const versionMatch = version.match(/(^|-)\d+(\.\d+)*($|-)/);
    if (!versionMatch) {
      throw new TypeError(`${version} is not a valid redis version`);
    }

    // Extract just the numbers and dots between first and last dash (or start/end)
    const versionNumbers = versionMatch[0].replace(/^-|-$/g, '');

    return versionNumbers.split('.').map(x => {
      const value = Number(x);
      if (Number.isNaN(value)) {
        throw new TypeError(`${version} is not a valid redis version`);
      }
      return value;
    });
  }
  static #getVersion(
    tagArgumentName: string,
    versionArgumentName: string | undefined,
    defaultVersion: string | { tag: string; version: string } = 'latest'
  ): Version {

View on GitHub (pinned to 90fd0652bc)

Solutions

  1. Pass a version containing a numeric run such as '7.4', '7.2.4', or '7.4-rc2' (the regex matches the 7.4 portion).
  2. Use the special tokens 'latest' or 'edge', which short-circuit to [Infinity] before the regex runs.
  3. Keep a non-numeric tag but supply --redis-version explicitly with a numeric value; #getVersion prioritizes the explicit version over the tag.
  4. If you need a non-numeric tag with no numeric component, extend the special-case list or adjust the regex rather than fighting the parser.

Example fix

// before — non-numeric tag, regex finds no digit run
 TestUtils.parseVersionNumber('alpine') // throws

// after — supply a numeric version, or use a tag containing digits
 TestUtils.parseVersionNumber('7.4-alpine') // -> [7, 4]
 // or keep the tag and pass --redis-version=7.4.0 on the CLI
Defensive patterns

Strategy: validation

Validate before calling

const VERSION_LIKE = /(^|-)\d+(\.\d+)*($|-)/;
function isParsableVersion(v: string): boolean {
  return v === 'latest' || v === 'edge' || VERSION_LIKE.test(v);
}
// before calling TestUtils.parseVersionNumber(tag):
if (!isParsableVersion(tag)) throw new Error(`Tag '${tag}' has no numeric version; pass --redis-version=N.N`);

Type guard

const isVersionString = (v: unknown): v is string =>
  typeof v === 'string' && (v === 'latest' || v === 'edge' || /(^|-)\d+(\.\d+)*($|-)/.test(v));

Try / catch

try {
  TestUtils.parseVersionNumber(maybeTag);
} catch (e) {
  if (e instanceof TypeError) {
    // fall back to an explicit numeric version, or fail fast with actionable guidance
    throw new Error(`Unparseable image tag '${maybeTag}'; set --redis-version=N.N.N`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing a tag or version string with no bounded numeric run: e.g. 'alpine', 'nightly', 'rc', or any purely alphabetic label. Reached via #getVersion from --docker-image-arg/--redis-version CLI args or the defaultVersion option when the resolved versionToParse is non-numeric.

Common situations: CI overrides the image tag with a word label (not 'latest'/'edge'); a typo in --redis-version; a custom defaultVersion object whose version field is a non-numeric label; using an image tag scheme the parser doesn't anticipate.

Related errors


AI-assisted analysis of redis/node-redis@90fd0652bc (2026-08-11). Data as JSON: /api/errors/33f38e3c8886a4b0. Report an issue: GitHub.