{"record":{"id":"8e5cf35d4f281c32","repo":"dotnet/aspnetcore","slug":"the-workspace-path-was-not-provided-8e5cf3","errorCode":null,"errorMessage":"The workspace path was not provided.","messagePattern":"The workspace path was not provided\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"eng/scripts/npm/update-dependency-versions.mjs","lineNumber":14,"sourceCode":"import path from 'path';\nimport { execSync } from 'child_process';\nimport fs from 'fs-extra';\n\nexport function applyVersions(defaultPackageVersion, workspacePath) {\n  // Get the workspace package.json from the provided path\n  const workspacePackage = fs.readJsonSync(workspacePath);\n\n  // Get the workspace directory\n  const workspaceDir = path.dirname(workspacePath);\n\n  // Validate and throw if the arguments are not provided\n  if (!workspacePath) {\n    throw new Error('The workspace path was not provided.');\n  }\n\n  if (!defaultPackageVersion) {\n    throw new Error('The default package version was not provided.');\n  }\n\n  const packages = workspacePackage.workspaces;\n  const packagesToPack = [];\n  for (const pkg of packages) {\n    const packagePath = path.resolve(workspaceDir, pkg, 'package.json');\n    const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));\n    if (!packageJson.private) {\n      packagesToPack.push([packagePath, packageJson]);\n    } else {\n      console.log(`Skipping ${packageJson.name} because it is marked as private.`);\n    }\n  }\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/eng/scripts/npm/update-dependency-versions.mjs#L1-L32","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the caller passes a real workspace package.json path - pack-workspace.mjs already validates this at its own line 21-23.","Fix the latent bug by moving the readJsonSync call to after the validation checks.","Supply the workspace path positional arg to pack-workspace.mjs so applyVersions receives it."],"exampleFix":"// before (latent bug - readJsonSync throws first)\nexport function applyVersions(defaultPackageVersion, workspacePath) {\n  const workspacePackage = fs.readJsonSync(workspacePath);\n  if (!workspacePath) { throw new Error('The workspace path was not provided.'); }\n// after\nexport function applyVersions(defaultPackageVersion, workspacePath) {\n  if (!workspacePath) { throw new Error('The workspace path was not provided.'); }\n  const workspacePackage = fs.readJsonSync(workspacePath);","handlingStrategy":"validation","validationCode":"// Fix the latent ordering bug: validate BEFORE readJsonSync\nif (!workspacePath || typeof workspacePath !== 'string') {\n    throw new Error('The workspace path was not provided.');\n}\nconst workspacePackage = fs.readJsonSync(workspacePath);","typeGuard":"const isNonEmptyString = (s) => typeof s === 'string' && s.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Move the readJsonSync call below the workspacePath/defaultPackageVersion guards.","Validate args at the entry point (pack-workspace.mjs already does this for its own argv).","Add a unit test that applyVersions(undefined, ...) throws the intended error, not an ENOENT."],"tags":["nodejs","npm","build","arguments","bug"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}