Yeachan-Heo/oh-my-codex · error · Error

Invalid session id. Expected 1-128 alphanumeric, underscore,

Error message

Invalid session id. Expected 1-128 alphanumeric, underscore, or dash characters.

What it means

The imagegen continuation CLI validates session ids against a pattern allowing 1-128 characters of letters, digits, underscores, and dashes. A session id containing other characters (spaces, slashes, dots, unicode) or exceeding 128 chars is rejected to keep session ids filesystem-safe.

Source

Thrown at src/imagegen/continuation.ts:66

}

const DEFAULT_ACTOR = "omx-imagegen";
const SESSION_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;

function sessionImagegenPendingPath(cwd: string, sessionId: string): string {
  return join(cwd, ".omx", "state", "sessions", sessionId, "imagegen-pending.json");
}

function normalizeRequired(value: string | undefined, name: string): string {
  const normalized = value?.trim() ?? "";
  if (!normalized) throw new Error(`Missing required ${name}`);
  return normalized;
}

function normalizeSessionId(sessionId: string): string {
  const normalized = normalizeRequired(sessionId, "session id");
  if (!SESSION_ID_PATTERN.test(normalized)) {
    throw new Error("Invalid session id. Expected 1-128 alphanumeric, underscore, or dash characters.");
  }
  return normalized;
}

function normalizeIsoOrNow(value: string | undefined, nowIso: string): string {
  const normalized = value?.trim();
  if (!normalized || normalized.toLowerCase() === "now") return nowIso;
  const parsed = Date.parse(normalized);
  if (!Number.isFinite(parsed)) {
    throw new Error(`Invalid --after timestamp: ${value}`);
  }
  return new Date(parsed).toISOString();
}

function defaultResumeInstruction(
  record: Omit<ImagegenContinuationRecord, "resume_instruction">,
  pendingPath: string,
): string {

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Use only alphanumeric, underscore, and dash characters, max 128
  2. Generate ids with a safe slug function in the calling code
  3. URL-encode or slugify external identifiers before passing them as session ids

Example fix

// before
omx imagegen continuation "my session/2024"
// after
omx imagegen continuation my-session-2024
Defensive patterns

Strategy: type-guard

Validate before calling

const SESSION_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
if (!SESSION_ID_PATTERN.test(sessionId)) sessionId = sessionId.replace(/[^A-Za-z0-9_-]/g,'-').slice(0,128);

Type guard

function isValidSessionId(id: string): boolean { return /^[A-Za-z0-9_-]{1,128}$/.test(id); }

Prevention

When it happens

Trigger: normalizeSessionId receives a session id failing SESSION_ID_PATTERN: empty, >128 chars, or containing characters outside [A-Za-z0-9_-].

Common situations: Passing a generated UUID with braces, a path-like id, a name with spaces, or a truncated/oversized generated identifier.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/c237031e38b1b33c. Report an issue: GitHub.