Skip to content

Commit

Permalink
Validate action description in factories
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Nov 20, 2024
1 parent 8cf3464 commit 627dfaa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ export class CommandRunnerImpl implements CommandRunner {

default: {
const action = this.actions[actionDescriptor.name];

// Ensure we don't miss any new actions. Needed because we don't have input validation.
if (action == null) {
throw new Error(`Unknown action: ${actionDescriptor.name}`);
}

this.finalStages = action.getFinalStages?.() ?? [];
this.noAutomaticTokenExpansion =
action.noAutomaticTokenExpansion ?? false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ export class MarkStageFactoryImpl implements MarkStageFactory {
return new TargetMarkStage(this.targetPipelineRunner, mark);
case "explicit":
return new ExplicitMarkStage(mark);
default: {
// Ensure we don't miss any new marks. Needed because we don't have input validation.
const _exhaustiveCheck: never = mark;
const { type } = mark;
throw new Error(`Unknown mark: ${type}`);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ export class ModifierStageFactoryImpl implements ModifierStageFactory {
throw Error(
`Unexpected modifier '${modifier.type}'; it should have been removed during inference`,
);
default: {
// Ensure we don't miss any new modifiers. Needed because we don't have input validation.
const _exhaustiveCheck: never = modifier;
const { type } = modifier;
throw new Error(`Unknown modifier: ${type}`);
}
}
}

Expand Down

0 comments on commit 627dfaa

Please sign in to comment.