fix(tenants): seed lookup config for tenants reached off the PSA path #222
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pms-288-seed-lookup-config-on-placement"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Seeds the PSA per-tenant lookup/config set for tenants a user is placed into off the PSA creation path, so ticket creation no longer 500s with
CONFIGURATION_ERROR. Closes PMS-288.create_tenantandensure_personal_tenantseed at creation, butplace_bunyip_useronly callsensure_personal_tenantfor brand-new or default-tenant-stuck users. A user already placed elsewhere - an invite into an auth/SSO-created org tenant, or an existing placement in a manually-created tenant - is not re-homed and never triggers the seed. That tenant has no defaultticket_statusesrow and noticket_sequencesrow, soPOST /api/v1/tickets500s (surfaced by the E2E suite).Change
TenantService::ensure_default_config(tenant_id)(new, public): idempotently seeds the per-tenant sequences (ON CONFLICTon thetenant_idPK, under the tenant GUC likecreate_tenant) and the lookup/config set (copy_default_config, which early-returns when already seeded).copy_default_configalone is insufficient - it does not seedticket_sequences, whichnext_ticket_numberrequires (tickets/service.rs:113-129).place_bunyip_user(auth/middleware.rs): callsensure_default_config(target)oncetargetis resolved, covering the invite and existing-placement branches the current code misses. No-op for the already-seeded personal-tenant branch and for already-seeded tenants. Best-effort: a seed failure is logged, not fatal to the request.Tests (both fail on the pre-fix code)
ensure_default_config_seeds_off_psa_tenant_idempotently(tests/tenants.rs): a bare org tenant gains a default ticket status + a sequence row; a second call adds no duplicates.placement_seeds_off_psa_target_tenant_so_tickets_create(tests/bunyip_login.rs): a user placed in a manually-created unseeded org tenant can create a ticket end-to-end (exercises both the default-status lookup andnext_ticket_number).Verification
cargo fmt --all --checkclean;cargo clippy --bin mokosh-server --test tenants --test bunyip_loginclean.Notes
Interim staging unblock (the one-off SQL seed of the three ticket lookups) is no longer needed once this deploys - any tenant a user lands in is seeded on the authenticated request. Relates to PMS-287 (the
create_tenantkindfix); distinct code path.