can1357/oh-my-pi · error · Error

Invalid alias "${aliasName}". Alias names must match ${ALIAS

Error message

Invalid alias "${aliasName}". Alias names must match ${ALIAS_NAME_RE.source}.

What it means

validateAliasName checks a profile alias name against ALIAS_NAME_RE before creating the shell alias; names with invalid characters or shape are rejected with the regex shown in the message. Further checks (below the throw) also forbid shadowing the base `omp` command and shell reserved words.

Source

Thrown at packages/coding-agent/src/cli/profile-alias.ts:155

}

function getReservedAliasNames(shell: ProfileAliasShell): ReadonlySet<string> {
	switch (shell) {
		case "bash":
		case "zsh":
			return POSIX_RESERVED_ALIAS_NAMES;
		case "fish":
			return FISH_RESERVED_ALIAS_NAMES;
		case "powershell":
		case "pwsh":
			return POWERSHELL_RESERVED_ALIAS_NAMES;
	}
}

function validateAliasName(aliasName: string, shell: ProfileAliasShell): string {
	const normalized = aliasName.trim();
	if (!ALIAS_NAME_RE.test(normalized)) {
		throw new Error(`Invalid alias "${aliasName}". Alias names must match ${ALIAS_NAME_RE.source}.`);
	}
	if (normalized.toLowerCase() === "omp") {
		throw new Error('Invalid alias "omp". Refusing to shadow the base omp command.');
	}
	if (getReservedAliasNames(shell).has(normalized.toLowerCase())) {
		throw new Error(`Invalid alias "${aliasName}". Refusing to create a ${shell} reserved word.`);
	}
	return normalized;
}

// On Windows the launching shell is rarely exported through $SHELL, so when it
// is missing we infer the PowerShell edition from the inherited environment.
// PowerShell 7 (pwsh) always seeds PSModulePath with separator-delimited
// ".../PowerShell/..." module directories (plus the Windows PowerShell ones for
// back-compat), whereas Windows PowerShell 5.1 only ever lists
// ".../WindowsPowerShell/...". The separator anchors keep "WindowsPowerShell"
// from matching. POWERSHELL_DISTRIBUTION_CHANNEL is set only by some pwsh
// distributions, so it stays a secondary hint rather than the primary signal.

View on GitHub (pinned to 9690622007)

Solutions

  1. Use a name matching the regex shown in the error (typically [A-Za-z][A-Za-z0-9_-]* style — check the message for the exact pattern).
  2. Strip spaces and shell metacharacters from the alias name.
  3. Avoid reserved words and the literal name `omp` (separate but adjacent checks).

Example fix

// before
omp alias "my helper!" -- cmd
// after
omp alias "my-helper" -- cmd
Defensive patterns

Strategy: validation

Validate before calling

// mirror the library's own regex before invoking
const ALIAS_NAME_RE = /^[A-Za-z][A-Za-z0-9_-]*$/; // replace with the pattern printed in the error
if (!ALIAS_NAME_RE.test(aliasName.trim())) throw new Error(`Bad alias name: ${aliasName}`);

Try / catch

try {
  await createProfileAlias(aliasName, cmd);
} catch (e) {
  if (e instanceof Error && e.message.startsWith("Invalid alias")) {
    console.error(e.message); // shows the required pattern
    process.exitCode = 1;
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling aliasName/validateAliasName with a name failing ALIAS_NAME_RE — e.g. containing spaces, slashes, quotes, leading digits, or shell metacharacters like `$`, `|`, `;`.

Common situations: Typing an alias with spaces (`omp alias "my alias"`), pasting a path as an alias name, or attempting aliases with punctuation that shells disallow.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/ac26c17898693571. Report an issue: GitHub.