diegosouzapw/OmniRoute · error · LeaseContextError
LEASE_CONTEXT_REQUIRED
LEASE_CONTEXT_REQUIRED
Error message
Explicit lease owner required
What it means
LeaseContextError (400, LEASE_CONTEXT_REQUIRED) from parseLeaseOwnerHeader(): a request participating in lease management carries no lease-owner header (missing or whitespace-only LEASE_OWNER_HEADER). Lease-scoped operations require an explicit owner identity to attribute and arbitrate the lease.
Solutions
- Client must send the LEASE_OWNER_HEADER with a non-empty owner id
- Ensure the SDK/agent generating lease requests sets the owner header on every call
- Check intermediaries/proxies are not stripping the custom header
- Return 400 LEASE_CONTEXT_REQUIRED so callers can fix their request
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/sse/services/leaseContext.ts:52 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/dc9d19a62ae11fac.
Report an issue: GitHub.
Appendix: source
Thrown at src/sse/services/leaseContext.ts:52
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() ?? "";
if (!/^[1-9]\d*$/.test(rawGeneration))
throw new LeaseContextError(400, "LEASE_CONTEXT_INVALID", "Positive lease generation required");
const generation = Number(rawGeneration);
if (!Number.isSafeInteger(generation))
throw new LeaseContextError(
400,
"LEASE_CONTEXT_INVALID",
"The lease generation header is invalid"
);
return { leaseOwnerId, generation };View on GitHub (pinned to a179ffed5b)