diegosouzapw/OmniRoute · error · LeaseContextError

LEASE_KEY_CONFIGURATION_INVALID

LEASE_KEY_CONFIGURATION_INVALID

Error message

Exclusive lease keys require explicit allowed connections

What it means

LeaseContextError (403, LEASE_KEY_CONFIGURATION_INVALID) from validateExclusiveLeaseKeyConfiguration(): a lease key is marked with the exclusive scope but its metadata has no allowedConnections list. Exclusive leases narrow a key to specific connections by design, so an empty/missing list is a configuration error, not a runtime state.

Solutions

  1. Add at least one connection id to the lease key's allowedConnections metadata
  2. Remove the exclusive scope from the key if it should be usable with any connection
  3. Fix the key-creation API/admin path that allowed an exclusive key with no allowlist
  4. Return 403 with LEASE_KEY_CONFIGURATION_INVALID to the caller presenting the key
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/sse/services/leaseContext.ts:42 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/e24c96de7074978e. Report an issue: GitHub.

Appendix: source

Thrown at src/sse/services/leaseContext.ts:42

    super(message);
  }
}

type LeaseKeyMetadata = {
  scopes?: readonly string[] | null;
  allowedConnections?: readonly string[] | null;
};

export function isExclusiveLeaseManagedKey(metadata: LeaseKeyMetadata | null | undefined): boolean {
  return Array.isArray(metadata?.scopes) && metadata.scopes.includes(LEASE_EXCLUSIVE_SCOPE);
}

export function validateExclusiveLeaseKeyConfiguration(
  metadata: LeaseKeyMetadata | null | undefined
): void {
  if (!isExclusiveLeaseManagedKey(metadata)) return;
  if (!metadata?.allowedConnections?.length)
    throw new LeaseContextError(
      403,
      "LEASE_KEY_CONFIGURATION_INVALID",
      "Exclusive lease keys require explicit allowed connections"
    );
}

export function parseLeaseOwnerHeader(headers: Headers): string {
  const leaseOwnerId = headers.get(LEASE_OWNER_HEADER)?.trim() ?? "";
  if (!leaseOwnerId)
    throw new LeaseContextError(400, "LEASE_CONTEXT_REQUIRED", "Explicit lease owner required");
  if (!LEASE_OWNER_PATTERN.test(leaseOwnerId))
    throw new LeaseContextError(400, "LEASE_CONTEXT_INVALID", "Malformed lease owner");
  return leaseOwnerId;
}

export function parseManagedLeaseRequestContext(headers: Headers): ManagedLeaseRequestContext {
  const leaseOwnerId = parseLeaseOwnerHeader(headers);
  const rawGeneration = headers.get(LEASE_GENERATION_HEADER)?.trim() ?? "";

View on GitHub (pinned to a179ffed5b)