{"record":{"id":"34dc1cd1524a3652","repo":"cypress-io/cypress","slug":"failed-generating-files-results-failed-map-e","errorCode":null,"errorMessage":"Failed generating files: ${results.failed.map((e) => `${e}`)}","messagePattern":"Failed generating files: (.+?)`\\)\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/data-context/src/actions/CodegenActions.ts","lineNumber":159,"sourceCode":"    const projectRoot = this.ctx.currentProject\n\n    assert(projectRoot, `Cannot create e2e directory without currentProject.`)\n\n    return path.join(projectRoot, 'cypress', 'e2e')\n  }\n\n  async e2eExamples (): Promise<NexusGenObjects['ScaffoldedFile'][]> {\n    const projectRoot = this.ctx.currentProject\n\n    assert(projectRoot, `Cannot create spec without currentProject.`)\n\n    const results = await codeGenerator(\n      { templateDir: templates['e2eExamples'], target: this.defaultE2EPath },\n      {},\n    )\n\n    if (results.failed.length) {\n      throw new Error(`Failed generating files: ${results.failed.map((e) => `${e}`)}`)\n    }\n\n    return results.files.map(({ status, file, content }) => {\n      return {\n        status: (status === 'add' || status === 'overwrite') ? 'valid' : 'skipped',\n        file: { absolute: file, contents: content },\n        description: 'Generated spec',\n      }\n    })\n  }\n\n  getWizardFrameworkFromConfig (): Cypress.ResolvedComponentFrameworkDefinition | undefined {\n    const config = this.ctx.lifecycleManager.loadedConfigFile\n\n    // If devServer is a function, they are using a custom dev server.\n    if (!config?.component?.devServer || typeof config?.component?.devServer === 'function') {\n      return undefined\n    }","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/cypress-io/cypress/blob/0d85fdc91230885bca0a91df278312800a48b727/packages/data-context/src/actions/CodegenActions.ts#L141-L177","documentation":"Thrown by CodegenActions.e2eExamples after running the code generator for e2e example specs. The codegen returns a results object with `.failed` and `.files`; if any file failed to generate (status other than add/overwrite/skip in the expected sense), Cypress aggregates the per-file error strings into one message and throws. Each entry in results.failed is itself an Error or error-like object stringified via template literal.","triggerScenarios":"Clicking 'Scaffold examples' in the Launchpad / create-spec wizard for e2e when one of the template files cannot be written — destination directory not writable, template file missing from the bundled templates map, or a copy conflict the generator classifies as a hard failure rather than skip.","commonSituations":"Read-only project root, antivirus locking files on Windows, partial Cypress install missing the e2eExamples template bundle, or a destination path that already exists and the generator's overwrite policy treats it as failure.","solutions":["Read the aggregated failed list in the error message — it tells you which file(s) and why.","Ensure the target directory (defaultE2EPath) is writable and not locked by another process.","Reinstall Cypress to restore the bundled templates (`npm install cypress`).","If a conflict on an existing file is the cause, delete or move the existing file and retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { access, constants } from 'fs/promises'\n\nasync function isTargetWritable (dir: string): Promise<boolean> {\n  try {\n    await access(dir, constants.W_OK)\n    return true\n  } catch { return false }\n}","typeGuard":"function codegenSucceeded (results: { failed: unknown[] }): boolean {\n  return results.failed.length === 0\n}","tryCatchPattern":"try {\n  await ctx.actions.e2eExamples()\n} catch (e) {\n  if (/Failed generating files/.test(e.message)) {\n    // Surface the per-file reasons from results.failed to the Launchpad UI\n    showScaffoldFailure(e.message)\n    return\n  }\n  throw e\n}","preventionTips":["Confirm the target directory is writable before scaffolding.","Reinstall Cypress if templates are missing.","Move conflicting existing files before re-scaffolding."],"tags":["codegen","scaffolding","launchpad","filesystem"],"backgroundTag":null,"analyzedSha":"0d85fdc91230885bca0a91df278312800a48b727","analyzedAt":"2026-08-12T16:24:28.056Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}