Skip to content

[Bug] getVersion silently returns empty string when version cannot be parsed causing misleading error messages #303

@zakaziko86

Description

@zakaziko86

Bug Description

getVersion in src/lib/clients/system.ts (lines 52-72) silently
returns empty string when the version regex doesn't match tool output.

Root Cause

If toolResponse.stdout.match(/(\d+\.\d+\.\d+)/) returns null,
the inner try block completes without exception, inner catch is
never triggered, and the function falls through to return ""
at line 72.

Impact

The caller checkVersion then calls:
semver.satisfies("", ">=18.0.0") → returns false

This throws a misleading VersionRequiredError:

"Docker 25.0.0 or higher is required. Please update Docker"

When Docker IS the right version — the output format simply
didn't match the regex.

Steps to Reproduce

  1. Install a tool whose --version output doesn't match
    \d+\.\d+\.\d+ pattern (e.g., outputs v22.0.0)
  2. Run genlayer up
  3. Observe misleading "please update" error

Suggested Fix

if (versionMatch) {
  return versionMatch[1];
}
// Add this:
throw new Error(`Could not parse ${toolName} version from output: ${toolResponse.stdout}`);

File

src/lib/clients/system.ts lines 52-72
Severity: High
Already reported: No

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions