openclaw/openclaw · error · Error

Crabbox lease id is invalid

Error message

Crabbox lease id is invalid

What it means

Thrown by resolveLeaseContext when lease.leaseId does not match LEASE_ID_PATTERN (/^(?:cbx_|tbx_)[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u). Only cbx_- or tbx_-prefixed ids of the right charset/length are accepted; anything else is treated as a programming/caller error before any command runs.

Source

Thrown at extensions/crabbox/src/crabbox-worker-provider.ts:582

  const resolveBinary = (explicit?: string) => {
    if (explicit) {
      return explicit;
    }
    defaultBinary ??= resolveCrabboxBinary({
      explicit,
      isExecutable: dependencies.isExecutable,
      openclawRoot,
      pathEnv: dependencies.pathEnv ?? process.env.PATH,
      platform: dependencies.platform,
    });
    return defaultBinary;
  };
  const resolveLeaseContext = (
    lease: Parameters<WorkerProvider["inspect"]>[0],
  ): LeaseCommandContext => {
    const parsed = parseCrabboxProfile(lease.profile);
    if (!LEASE_ID_PATTERN.test(lease.leaseId)) {
      throw new Error("Crabbox lease id is invalid");
    }
    return {
      binary: resolveBinary(parsed.binary),
      id: lease.leaseId,
      provider: parsed.provider,
    };
  };

  return {
    id: CRABBOX_WORKER_PROVIDER_ID,
    resolveProvisionTimeoutMs(profile) {
      return resolveCrabboxProvisionCallTimeoutMs(parseCrabboxProfile(profile));
    },
    async provision(profile: WorkerProfile, operationId: string): Promise<WorkerLease> {
      const parsed = parseCrabboxProfile(profile);
      const warmupTimeoutMs = parsed.desktop
        ? CRABBOX_DESKTOP_WARMUP_TIMEOUT_MS
        : CRABBOX_WARMUP_TIMEOUT_MS;

View on GitHub (pinned to 01804a7531)

Solutions

  1. Use the lease id returned by provision (operationLeaseId(operationId)), not the operationId or slug.
  2. Validate the id against the cbx_/tbx_ pattern before passing it to inspect/destroy.
  3. If migrating formats, regenerate ids via operationLeaseId so they carry the correct prefix.

Example fix

// before - passing the operation id
provider.inspect({ leaseId: operationId, profile });
// after - passing the derived lease id
const leaseId = operationLeaseId(operationId); // e.g. cbx_a1b2c3d4e5f6
provider.inspect({ leaseId, profile });
Defensive patterns

Strategy: validation

Validate before calling

const LEASE_ID_PATTERN = /^(?:cbx_|tbx_)[A-Za-z0-9][A-Za-z0-9_-]{0,128}$/u;
function assertLeaseId(id) {
  if (!LEASE_ID_PATTERN.test(id)) {
    throw new Error(`Invalid lease id: ${id}`);
  }
}

Type guard

function isValidLeaseId(id) {
  return typeof id === 'string' && /^(?:cbx_|tbx_)[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u.test(id);
}

Prevention

When it happens

Trigger: Calling inspect/resolveSshIdentity/destroy with a malformed leaseId: missing cbx_/tbx_ prefix, empty string, wrong prefix, overlong id, or illegal characters.

Common situations: Caller stored a raw operationId instead of the derived lease id; copy/paste truncated the id; mixed Crabbox and Testbox ids; caller fabricated an id locally.

Related errors


AI-assisted analysis of openclaw/openclaw@01804a7531 (2026-08-12). Data as JSON: /api/errors/2322ea7649df27b7. Report an issue: GitHub.