{"record":{"id":"ac26c17898693571","repo":"can1357/oh-my-pi","slug":"invalid-alias-aliasname-alias-names-must-mat","errorCode":null,"errorMessage":"Invalid alias \"${aliasName}\". Alias names must match ${ALIAS_NAME_RE.source}.","messagePattern":"Invalid alias \"(.+?)\"\\. Alias names must match (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/profile-alias.ts","lineNumber":155,"sourceCode":"}\n\nfunction getReservedAliasNames(shell: ProfileAliasShell): ReadonlySet<string> {\n\tswitch (shell) {\n\t\tcase \"bash\":\n\t\tcase \"zsh\":\n\t\t\treturn POSIX_RESERVED_ALIAS_NAMES;\n\t\tcase \"fish\":\n\t\t\treturn FISH_RESERVED_ALIAS_NAMES;\n\t\tcase \"powershell\":\n\t\tcase \"pwsh\":\n\t\t\treturn POWERSHELL_RESERVED_ALIAS_NAMES;\n\t}\n}\n\nfunction validateAliasName(aliasName: string, shell: ProfileAliasShell): string {\n\tconst normalized = aliasName.trim();\n\tif (!ALIAS_NAME_RE.test(normalized)) {\n\t\tthrow new Error(`Invalid alias \"${aliasName}\". Alias names must match ${ALIAS_NAME_RE.source}.`);\n\t}\n\tif (normalized.toLowerCase() === \"omp\") {\n\t\tthrow new Error('Invalid alias \"omp\". Refusing to shadow the base omp command.');\n\t}\n\tif (getReservedAliasNames(shell).has(normalized.toLowerCase())) {\n\t\tthrow new Error(`Invalid alias \"${aliasName}\". Refusing to create a ${shell} reserved word.`);\n\t}\n\treturn normalized;\n}\n\n// On Windows the launching shell is rarely exported through $SHELL, so when it\n// is missing we infer the PowerShell edition from the inherited environment.\n// PowerShell 7 (pwsh) always seeds PSModulePath with separator-delimited\n// \".../PowerShell/...\" module directories (plus the Windows PowerShell ones for\n// back-compat), whereas Windows PowerShell 5.1 only ever lists\n// \".../WindowsPowerShell/...\". The separator anchors keep \"WindowsPowerShell\"\n// from matching. POWERSHELL_DISTRIBUTION_CHANNEL is set only by some pwsh\n// distributions, so it stays a secondary hint rather than the primary signal.","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/profile-alias.ts#L137-L173","documentation":"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.","triggerScenarios":"Calling aliasName/validateAliasName with a name failing ALIAS_NAME_RE — e.g. containing spaces, slashes, quotes, leading digits, or shell metacharacters like `$`, `|`, `;`.","commonSituations":"Typing an alias with spaces (`omp alias \"my alias\"`), pasting a path as an alias name, or attempting aliases with punctuation that shells disallow.","solutions":["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).","Strip spaces and shell metacharacters from the alias name.","Avoid reserved words and the literal name `omp` (separate but adjacent checks)."],"exampleFix":"// before\nomp alias \"my helper!\" -- cmd\n// after\nomp alias \"my-helper\" -- cmd","handlingStrategy":"validation","validationCode":"// mirror the library's own regex before invoking\nconst ALIAS_NAME_RE = /^[A-Za-z][A-Za-z0-9_-]*$/; // replace with the pattern printed in the error\nif (!ALIAS_NAME_RE.test(aliasName.trim())) throw new Error(`Bad alias name: ${aliasName}`);","typeGuard":null,"tryCatchPattern":"try {\n  await createProfileAlias(aliasName, cmd);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"Invalid alias\")) {\n    console.error(e.message); // shows the required pattern\n    process.exitCode = 1;\n    return;\n  }\n  throw e;\n}","preventionTips":["Restrict alias input in scripts/wrappers to [A-Za-z0-9_-] with a leading letter.","Never pass user-supplied strings with spaces or shell metacharacters as alias names.","Avoid reserved shell words and the name `omp`."],"tags":["cli","validation","alias","configuration"],"backgroundTag":"invalid-identifier","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}