Tenant naming logic adjustments
All checks were successful
Build and Push / build (push) Successful in 1m22s

This commit is contained in:
2026-04-26 18:47:50 +02:00
parent 0bf4c6cf4c
commit 1f48712e42
3 changed files with 238 additions and 7 deletions

View File

@@ -14,6 +14,7 @@ import {
getDefaultAgentsMd,
generateToolsMd,
} from "@/lib/workspace-defaults";
import { deriveTenantName } from "@/lib/tenant-naming";
import { safeError } from "@/lib/errors";
/**
@@ -61,13 +62,14 @@ export async function POST(
const isReApproval = tenantRequest.status === "rejected";
// Derive tenant name from company name: lowercase, alphanumeric + hyphens
const tenantName =
tenantRequest.companyName
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-|-$/g, "")
.slice(0, 63) || `tenant-${tenantRequest.id.slice(0, 8)}`;
// Build the CR name: see `lib/tenant-naming.ts` for the format spec.
// For now all approvals are kind="company" — the personal branch is
// wired but unused until Slice 4 introduces the `is_personal` column.
const tenantName = deriveTenantName(
"company",
tenantRequest.companyName,
tenantRequest.id
);
try {
// Step 1: Decrypt and write package secrets to OpenBao (if collected during wizard)