can1357/oh-my-pi · error · Error
Invalid OMP profile "${profile}". Profile names must match $
Error message
Invalid OMP profile "${profile}". Profile names must match ${PROFILE_NAME_RE.source}, cannot be "." or "..", cannot end with ".", and cannot be a Windows reserved device name (CON, PRN, AUX, NUL, COM0-9, LPT0-9, or any of those with an extension). What it means
normalizeProfileName (packages/utils/src/dirs.ts) validates OMP profile names before using them as directory components. It rejects names that fail PROFILE_NAME_RE, are "."/"..", end with ".", or match Windows reserved device names, throwing with a message that spells out all rules.
Source
Thrown at packages/utils/src/dirs.ts:69
/**
* Normalize and validate a profile name. Returns `undefined` for the implicit
* default (empty string, whitespace, or the explicit "default" sentinel) and
* throws for syntactically invalid or platform-reserved names.
*
* Exported so consumers of `@oh-my-pi/pi-utils/dirs` (CLI bootstrap, tests,
* downstream tools) can validate user input without re-deriving the rules.
*/
export function normalizeProfileName(profile: string | undefined): string | undefined {
const normalized = profile?.trim();
if (!normalized || normalized === "default") return undefined;
if (
normalized === "." ||
normalized === ".." ||
normalized.endsWith(".") ||
!PROFILE_NAME_RE.test(normalized) ||
WINDOWS_RESERVED_BASENAME_RE.test(normalized)
) {
throw new Error(
`Invalid OMP profile "${profile}". Profile names must match ${PROFILE_NAME_RE.source}, ` +
`cannot be "." or "..", cannot end with ".", and cannot be a Windows reserved device name ` +
`(CON, PRN, AUX, NUL, COM0-9, LPT0-9, or any of those with an extension).`,
);
}
return normalized;
}
/**
* Resolve the active profile from the two profile env vars. `OMP_PROFILE` is the
* canonical variable and takes precedence; `PI_PROFILE` is the legacy
* compatibility fallback, consulted only when `OMP_PROFILE` is undefined. An
* explicitly-empty `OMP_PROFILE` therefore selects the default profile rather
* than silently inheriting `PI_PROFILE`. Delegates validation/normalization to
* {@link normalizeProfileName} (which throws on a syntactically invalid value).
*/
export function resolveProfileEnv(omp: string | undefined, pi: string | undefined): string | undefined {
return normalizeProfileName(omp !== undefined ? omp : pi);View on GitHub (pinned to 9690622007)
Solutions
- Rename the profile to match the allowed pattern shown in the error (alphanumeric/dash style per PROFILE_NAME_RE).
- Remove leading/trailing dots and path separators from the profile value.
- Avoid Windows reserved device names (CON, PRN, AUX, NUL, COM0-9, LPT0-9) even with extensions.
- Check where OMP_PROFILE is set (shell rc, CI secrets, .env) and fix the literal value.
Example fix
// before OMP_PROFILE="my profile." ome profile # Invalid OMP profile // after OMP_PROFILE="my-profile" ome profile
Defensive patterns
Strategy: validation
Validate before calling
const PROFILE_NAME_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/; // match repo rule
const RESERVED = /^(CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])(\..*)?$/i;
if (!PROFILE_NAME_RE.test(profile) || profile === '.' || profile === '..' || profile.endsWith('.') || RESERVED.test(profile)) {
throw new Error(`Invalid OMP profile: ${profile}`);
} Try / catch
try {
const p = normalizeProfileName(profile);
} catch (err) {
if (err.message.startsWith('Invalid OMP profile')) {
console.error(`${err.message}\nFix OMP_PROFILE in your shell env or config.`);
process.exitCode = 2;
return;
}
throw err;
} Prevention
- Use only letters, digits, dashes, and underscores in profile names.
- Never set OMP_PROFILE from untrusted/interpolated input without sanitizing.
- Avoid Windows reserved device names and trailing dots regardless of platform.
- Validate OMP_PROFILE in CI before running omp commands.
When it happens
Trigger: Setting OMP_PROFILE (or passing a profile to profile()/resolveProfileEnv()/next()/getProfileRootDir()) with a value containing illegal characters, path traversal (".."), a trailing dot, or a reserved name like "CON" or "COM1".
Common situations: Env files exporting OMP_PROFILE with spaces or slashes, CI configs using profile names like "default." or "aux", users attempting traversal-style profile values, Windows-reserved names chosen on any platform.
Related errors
- nameError (dynamic message from validateServerName, e.g. "Se
- Cannot register custom API "${api}": built-in API names are
- OMP_AUTH_BROKER_ACCOUNT_POOL_FILE contains an empty provider
- OMP_AUTH_BROKER_ACCOUNT_POOL_FILE contains a provider id wit
- ${name} path does not exist: ${trimmed}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/0960cc2bb1ad50bc.
Report an issue: GitHub.