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:
- 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. - With no context tenant, an explicit
fallbackis honoured — system code (jobs, CLI commands) can pin one tenant deliberately. - 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