Skip to content

basalt / tenancy/src / requireTenantId

Function: requireTenantId() ​

> requireTenantId(fallback?): string

Defined in: tenancy/src/scoped.ts:39

Fail-closed tenant id resolution with anti-widening semantics:

  1. A tenant in context always wins — a caller-supplied fallback (which may carry client input) can never widen or switch the scope of a request.
  2. With no context tenant, an explicit fallback is honoured — system code (jobs, CLI commands) can pin one tenant deliberately.
  3. Otherwise it THROWS instead of returning undefined — the value is always a real tenant id, never a filter that silently disappears.

Same rules as Audit.trail()'s hardened scoping.

Parameters ​

fallback? ​

string

Returns ​

string

Released under the MIT License.