diegosouzapw/OmniRoute · error

Unknown stage

Error message

Unknown stage: ${stage}

What it means

renderPrompt looked up STAGE_PROMPTS[stage] and found no template for the given pipeline stage name, meaning an unknown/typo'd StageName was passed. The prompt pipeline cannot render system/user prompts for a stage that has no registered template.

Solutions

  1. Constrain the stage parameter to the StageName type to catch typos at compile time
  2. Add the missing stage to STAGE_PROMPTS if it is a new pipeline stage
  3. List known stages in the error message for faster diagnosis
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/domain/prompts.ts:97 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/a3e861d9f9b59474. Report an issue: GitHub.

Appendix: source

Thrown at src/domain/prompts.ts:97

 * @returns Interpolated string
 */
export function interpolate(template: string, variables: Record<string, string>): string {
  return template.replace(/\{(\w+)\}/g, (match, key) => {
    return key in variables ? variables[key] : match;
  });
}

/**
 * Render a stage prompt with the given variables.
 *
 * @param stage - The pipeline stage name
 * @param variables - Variable values for interpolation
 * @returns Rendered system and user prompt strings
 */
export function renderPrompt(stage: StageName, variables: Record<string, string>): StagePrompt {
  const template = STAGE_PROMPTS[stage];
  if (!template) {
    throw new Error(`Unknown stage: ${stage}`);
  }
  return {
    system: interpolate(template.system, variables),
    user: interpolate(template.user, variables),
  };
}

View on GitHub (pinned to a179ffed5b)