ReactiveX/rxjs · error · Error
Migration result was refused for source: ${sourcePath}
Error message
Migration result was refused for source: ${sourcePath} What it means
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.
Source
Thrown at packages/migrate/src/node.ts:143
/** Writes the exact transformed bytes contained in an already validated plan. */
export async function applyMigrationPlan(
plan: MigrationFilePlan,
options: ApplyMigrationPlanOptions = {}
): Promise<readonly MigratedFile[]> {
await preflightPlanOutputs(plan, options);
for (const { outputPath, result } of plan.files) {
await mkdir(dirname(outputPath), { recursive: true });
await writeFile(outputPath, result.code, 'utf8');
}
return plan.files;
}
async function preflightPlanOutputs(plan: MigrationFilePlan, options: ApplyMigrationPlanOptions): Promise<void> {
const outputRoot = resolve(plan.outputRoot);
const canonicalOutputRoot = await canonicalFutureDirectory(outputRoot, 'outputRoot');
const canonicalOutputs = new Set<string>();
for (const { sourcePath, outputPath, result } of plan.files) {
if (result.status === 'refused') throw new Error(`Migration result was refused for source: ${sourcePath}`);
const resolvedOutputPath = resolve(outputPath);
if (resolvedOutputPath === outputRoot) throw new Error(`Output path must identify a file below outputRoot: ${outputPath}`);
assertContained(outputRoot, resolvedOutputPath, `Output path is outside outputRoot: ${outputPath}`);
const canonicalOutputPath = await canonicalFuturePath(resolvedOutputPath);
assertContained(canonicalOutputRoot, canonicalOutputPath, `Output path resolves outside outputRoot: ${outputPath}`);
if (canonicalOutputs.has(canonicalOutputPath)) throw new Error(`Duplicate output path: ${outputPath}`);
canonicalOutputs.add(canonicalOutputPath);
await assertWritableOutput(resolvedOutputPath, options.overwrite ?? false);
}
}
async function assertWritableOutput(outputPath: string, overwrite: boolean): Promise<void> {
try {
const outputStats = await lstat(outputPath);
if (outputStats.isSymbolicLink()) throw new Error(`Refusing to overwrite a symbolic link: ${outputPath}`);
if (!outputStats.isFile()) throw new Error(`Output path is not a regular file: ${outputPath}`);
if (!overwrite) throw new Error(`Output path already exists; enable overwrite explicitly: ${outputPath}`);
} catch (error: unknown) {View on GitHub (pinned to 54796b38a5)
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
Example fix
// before
await applyMigrationPlan(plan);
// after
const refused = plan.files.filter(f => f.result.status === 'refused');
if (refused.length) {
console.error('Refused:', refused.map(f => f.sourcePath));
} else {
await applyMigrationPlan(plan);
} Defensive patterns
Strategy: validation
Validate before calling
const plan = await planMigrationFiles(options);
const refused = plan.files.filter(f => f.result.status === 'refused');
if (refused.length === 0) {
await applyMigrationPlan(plan);
} Type guard
function isFullyMigratable(plan: MigrationFilePlan): boolean {
return plan.files.every(f => f.result.status !== 'refused');
} Try / catch
try {
await applyMigrationPlan(plan);
} catch (e) {
if (e instanceof Error && e.message.startsWith('Migration result was refused')) {
// log plan.files refused statuses and adjust inputs/mode
} else throw e;
} Prevention
- Always inspect plan.files statuses before applying when inputs are heterogeneous
- Set options.mode explicitly so refusal behavior is deterministic
When it happens
Trigger: Calling applyMigrationPlan (or migrateTestFiles with write:true) on a plan where at least one plan.files[].result.status === 'refused'.
Common situations: 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.
Related errors
- Duplicate output path: ${outputPath}
- Duplicate output path: ${outputLocalName}
- Output path must identify a file below outputRoot: ${outputP
- Refusing to overwrite a symbolic link: ${outputPath}
- Output path is not a regular file: ${outputPath}
AI-assisted analysis of ReactiveX/rxjs@54796b38a5 (2026-08-28).
Data as JSON: /api/errors/1545269b8a603bdf.
Report an issue: GitHub.