{"record":{"id":"1545269b8a603bdf","repo":"ReactiveX/rxjs","slug":"migration-result-was-refused-for-source-sourcep","errorCode":null,"errorMessage":"Migration result was refused for source: ${sourcePath}","messagePattern":"Migration result was refused for source: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/migrate/src/node.ts","lineNumber":143,"sourceCode":"/** Writes the exact transformed bytes contained in an already validated plan. */\nexport async function applyMigrationPlan(\n  plan: MigrationFilePlan,\n  options: ApplyMigrationPlanOptions = {}\n): Promise<readonly MigratedFile[]> {\n  await preflightPlanOutputs(plan, options);\n  for (const { outputPath, result } of plan.files) {\n    await mkdir(dirname(outputPath), { recursive: true });\n    await writeFile(outputPath, result.code, 'utf8');\n  }\n  return plan.files;\n}\n\nasync function preflightPlanOutputs(plan: MigrationFilePlan, options: ApplyMigrationPlanOptions): Promise<void> {\n  const outputRoot = resolve(plan.outputRoot);\n  const canonicalOutputRoot = await canonicalFutureDirectory(outputRoot, 'outputRoot');\n  const canonicalOutputs = new Set<string>();\n  for (const { sourcePath, outputPath, result } of plan.files) {\n    if (result.status === 'refused') throw new Error(`Migration result was refused for source: ${sourcePath}`);\n    const resolvedOutputPath = resolve(outputPath);\n    if (resolvedOutputPath === outputRoot) throw new Error(`Output path must identify a file below outputRoot: ${outputPath}`);\n    assertContained(outputRoot, resolvedOutputPath, `Output path is outside outputRoot: ${outputPath}`);\n    const canonicalOutputPath = await canonicalFuturePath(resolvedOutputPath);\n    assertContained(canonicalOutputRoot, canonicalOutputPath, `Output path resolves outside outputRoot: ${outputPath}`);\n    if (canonicalOutputs.has(canonicalOutputPath)) throw new Error(`Duplicate output path: ${outputPath}`);\n    canonicalOutputs.add(canonicalOutputPath);\n    await assertWritableOutput(resolvedOutputPath, options.overwrite ?? false);\n  }\n}\n\nasync function assertWritableOutput(outputPath: string, overwrite: boolean): Promise<void> {\n  try {\n    const outputStats = await lstat(outputPath);\n    if (outputStats.isSymbolicLink()) throw new Error(`Refusing to overwrite a symbolic link: ${outputPath}`);\n    if (!outputStats.isFile()) throw new Error(`Output path is not a regular file: ${outputPath}`);\n    if (!overwrite) throw new Error(`Output path already exists; enable overwrite explicitly: ${outputPath}`);\n  } catch (error: unknown) {","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/ReactiveX/rxjs/blob/54796b38a57e6309f9861e174737479bb3f63f61/packages/migrate/src/node.ts#L125-L161","documentation":"applyMigrationPlan refuses to write any file when the plan contains a result whose status is 'refused', meaning the migration engine declined to transform that source (for example, it did not recognize it as migratable under the selected mode). This is a fail-closed guard: no partial application happens, because writing the other files would leave an inconsistent migration.","triggerScenarios":"Calling applyMigrationPlan (or migrateTestFiles with write:true) on a plan where at least one plan.files[].result.status === 'refused'.","commonSituations":"Running the migrator in 'unselected' mode over a directory containing test files that do not match the expected framework, or passing extra files alongside migratable ones.","solutions":["Inspect plan.files to see which sources were refused and why, and remove them from the input set","Set an appropriate options.mode so the migrator accepts the sources instead of refusing them","If refusal is expected, keep write disabled and handle refused results programmatically instead of applying the plan"],"exampleFix":"// before\nawait applyMigrationPlan(plan);\n\n// after\nconst refused = plan.files.filter(f => f.result.status === 'refused');\nif (refused.length) {\n  console.error('Refused:', refused.map(f => f.sourcePath));\n} else {\n  await applyMigrationPlan(plan);\n}","handlingStrategy":"validation","validationCode":"const plan = await planMigrationFiles(options);\nconst refused = plan.files.filter(f => f.result.status === 'refused');\nif (refused.length === 0) {\n  await applyMigrationPlan(plan);\n}","typeGuard":"function isFullyMigratable(plan: MigrationFilePlan): boolean {\n  return plan.files.every(f => f.result.status !== 'refused');\n}","tryCatchPattern":"try {\n  await applyMigrationPlan(plan);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Migration result was refused')) {\n    // log plan.files refused statuses and adjust inputs/mode\n  } else throw e;\n}","preventionTips":["Always inspect plan.files statuses before applying when inputs are heterogeneous","Set options.mode explicitly so refusal behavior is deterministic"],"tags":["migrate","validation","refusal","plan-apply"],"backgroundTag":"migration-refused-no-write","analyzedSha":"54796b38a57e6309f9861e174737479bb3f63f61","analyzedAt":"2026-08-28T10:21:27.410Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}