dotnet/aspnetcore · error · Error

The workspace path was not provided.

Error message

The workspace path was not provided.

What it means

applyVersions in update-dependency-versions.mjs validates that workspacePath was supplied. NOTE a latent ordering bug: fs.readJsonSync(workspacePath) on line 7 runs BEFORE this check on line 13, so when workspacePath is undefined the script throws a readJsonSync error ('path must be a string' / ENOENT) before ever reaching this guard - the 'workspace path was not provided' throw is effectively unreachable for the missing-arg case.

Source

Thrown at eng/scripts/npm/update-dependency-versions.mjs:14

import path from 'path';
import { execSync } from 'child_process';
import fs from 'fs-extra';

export function applyVersions(defaultPackageVersion, workspacePath) {
  // Get the workspace package.json from the provided path
  const workspacePackage = fs.readJsonSync(workspacePath);

  // Get the workspace directory
  const workspaceDir = path.dirname(workspacePath);

  // Validate and throw if the arguments are not provided
  if (!workspacePath) {
    throw new Error('The workspace path was not provided.');
  }

  if (!defaultPackageVersion) {
    throw new Error('The default package version was not provided.');
  }

  const packages = workspacePackage.workspaces;
  const packagesToPack = [];
  for (const pkg of packages) {
    const packagePath = path.resolve(workspaceDir, pkg, 'package.json');
    const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));
    if (!packageJson.private) {
      packagesToPack.push([packagePath, packageJson]);
    } else {
      console.log(`Skipping ${packageJson.name} because it is marked as private.`);
    }
  }

View on GitHub (pinned to 3600ca084e)

Solutions

  1. Ensure the caller passes a real workspace package.json path - pack-workspace.mjs already validates this at its own line 21-23.
  2. Fix the latent bug by moving the readJsonSync call to after the validation checks.
  3. Supply the workspace path positional arg to pack-workspace.mjs so applyVersions receives it.

Example fix

// before (latent bug - readJsonSync throws first)
export function applyVersions(defaultPackageVersion, workspacePath) {
  const workspacePackage = fs.readJsonSync(workspacePath);
  if (!workspacePath) { throw new Error('The workspace path was not provided.'); }
// after
export function applyVersions(defaultPackageVersion, workspacePath) {
  if (!workspacePath) { throw new Error('The workspace path was not provided.'); }
  const workspacePackage = fs.readJsonSync(workspacePath);
Defensive patterns

Strategy: validation

Validate before calling

// Fix the latent ordering bug: validate BEFORE readJsonSync
if (!workspacePath || typeof workspacePath !== 'string') {
    throw new Error('The workspace path was not provided.');
}
const workspacePackage = fs.readJsonSync(workspacePath);

Type guard

const isNonEmptyString = (s) => typeof s === 'string' && s.trim().length > 0;

Prevention

When it happens

Trigger: Calling applyVersions(defaultPackageVersion, workspacePath) with workspacePath falsy. In practice you hit the earlier readJsonSync failure instead; this guard would only fire if readJsonSync were re-ordered or if a future change skipped it.

Common situations: A caller of applyVersions (currently only pack-workspace.mjs) passed an undefined workspacePath; normally pack-workspace.mjs:21-23 already gates this so applyVersions is reached only with a truthy path.

Related errors


AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11). Data as JSON: /api/errors/8e5cf35d4f281c32. Report an issue: GitHub.