{"record":{"id":"4d13f6f5dab015ac","repo":"cypress-io/cypress","slug":"no-spec-path","errorCode":"NO_SPEC_PATH","errorMessage":"`specPath` must be a non-empty string","messagePattern":"`specPath` must be a non-empty string","errorType":"error_code","errorClass":"RunSpecError","httpStatus":null,"severity":"error","filePath":"packages/data-context/src/actions/ProjectActions.ts","lineNumber":524,"sourceCode":"          new Promise((resolve) => setTimeout(resolve, 1000)),\n          browserStatusSubscription.next(),\n        ])\n\n        if (--maxIterations === 0) {\n          break\n        }\n      }\n\n      await browserStatusSubscription.return(undefined as any)\n    }\n\n    try {\n      if (!this.ctx.currentProject) {\n        throw new RunSpecError('NO_PROJECT', 'A project must be open prior to attempting to run a spec')\n      }\n\n      if (!specPath) {\n        throw new RunSpecError('NO_SPEC_PATH', '`specPath` must be a non-empty string')\n      }\n\n      let targetTestingType: TestingType\n\n      // Get relative path from the specPath to determine which testing type from the specPattern\n      const relativeSpecPath = path.relative(this.ctx.currentProject, specPath)\n\n      // Check to see whether input specPath matches the specPattern for one or the other testing type\n      // If it matches neither then we can't run the spec and we should error\n      if (await this.ctx.project.matchesSpecPattern(relativeSpecPath, 'e2e')) {\n        targetTestingType = 'e2e'\n      } else if (await this.ctx.project.matchesSpecPattern(relativeSpecPath, 'component')) {\n        targetTestingType = 'component'\n      } else {\n        throw new RunSpecError('NO_SPEC_PATTERN_MATCH', 'Unable to determine testing type, spec does not match any configured specPattern')\n      }\n\n      debug(`Spec %s matches '${targetTestingType}' pattern`, specPath)","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/cypress-io/cypress/blob/0d85fdc91230885bca0a91df278312800a48b727/packages/data-context/src/actions/ProjectActions.ts#L506-L542","documentation":"Thrown by ProjectActions.runSpec (ProjectActions.ts:523-525) with code NO_SPEC_PATH when the specPath argument is falsy (empty string, undefined, null). It is the second guard in runSpec, checked right after the project-open guard. Like the other RunSpecErrors it is caught by the surrounding try/catch and returned as { code: 'NO_SPEC_PATH', detailMessage }.","triggerScenarios":"Invoking runSpec({ specPath }) with an empty string, undefined, or null — e.g. a 'run all specs' request with no individual path, a UI event where no spec was selected, or a null leaking from a spec-list lookup.","commonSituations":"Clicking run before selecting a spec; a stale/null spec reference passed from the UI; calling the runSpec GraphQL mutation without a specPath argument; programmatic automation that assumes a spec is always selected.","solutions":["Validate specPath is a non-empty string before calling runSpec and skip/throw early in the caller.","In the UI, ensure a spec is selected (non-null) before enabling the run action.","Use the dedicated 'run all specs' path (RUN_ALL_SPECS) rather than passing an empty specPath to runSpec."],"exampleFix":"// before\nawait runSpec({ specPath: maybePath })\n\n// after\nif (typeof specPath !== 'string' || specPath.trim().length === 0) {\n  throw new Error('specPath must be a non-empty string')\n}\nawait runSpec({ specPath })","handlingStrategy":"validation","validationCode":"// Validate specPath before calling runSpec\nfunction isValidSpecPath(specPath: unknown): specPath is string {\n  return typeof specPath === 'string' && specPath.trim().length > 0\n}\n\nif (!isValidSpecPath(specPath)) {\n  throw new Error('A non-empty specPath is required')\n}\nawait ctx.actions.runSpec({ specPath })","typeGuard":"function isNonEmptyString(value: unknown): value is string {\n  return typeof value === 'string' && value.length > 0\n}\n\n// narrowing\nif (!isNonEmptyString(specPath)) {\n  // caller bug: do not invoke runSpec\n}","tryCatchPattern":null,"preventionTips":["Type the runSpec caller so specPath is string (non-optional); reject undefined/null at the GraphQL boundary.","Disable the run action in the UI until a spec is selected.","Use the explicit 'run all specs' entry point instead of passing an empty string to runSpec."],"tags":["runspec","validation","spec-path","input-validation"],"backgroundTag":null,"analyzedSha":"0d85fdc91230885bca0a91df278312800a48b727","analyzedAt":"2026-08-12T16:24:28.056Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}