fix(tenants): name a personal tenant after its owner #503
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/PMS-743-personal-tenant-name"
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?
Closes PMS-743.
Problem
Every auto-provisioned tenant was named the constant "My workspace" (
src/modules/tenants/service.rs:263), and that name goes to external recipients: the client request-form email subject ({{form_name}} request form from {{tenant_name}}) and the invitation email.Staging had eight tenants sharing that name, one per person who has ever signed in, so eight MSPs' clients would receive mail from "My workspace" until each owner intervened by hand. Found while verifying MAPPS-425, where a real client email arrived reading
longle request form from My workspace.The constant was not wrong when personal tenants landed. The slug is uuid-derived precisely so provisioning needs no human name, and nothing external rendered the display name then. Both emailed surfaces arrived later.
What this does
ensure_personal_tenantnow takes the IdP'sgiven_nameandemail. The placement path already held both (middleware.rs:654-663) and passed neither. Preference order:Step 2 reuses
synthetic_name_from_emailrather than reimplementing its rules. That helper already refuses to derive a name from mokosh's own@unresolved.invalidJIT placeholder, from a UUID local-part, or from a local-part with no usable segments, and those are exactly the cases that must not become a tenant name. It is nowpub(crate)alongside its fallback pair, so a caller can tell "derived from the user" from "gave up".Falling back to the generic is deliberate rather than clever: "Mokosh User's workspace" or "7fa2b249's workspace" reads worse to a client than the honest generic, and the owner can rename it in Settings either way now that mokosh-apps #493 has merged.
The derived name is truncated to the
VARCHAR(255)column width instead of being allowed to fail the insert. Provisioning runs on someone's very first login; a long name must not be what breaks it.The possessive is always
's, including after a trailing s ("Chris's workspace"). Common style, and no branching on spelling.Not done, on purpose
Existing "My workspace" rows are untouched. Renaming a tenant changes the phrase its owner must type to confirm a data import, so a backfill should be an explicit decision rather than a side effect of a deploy. Owners rename through Settings.
Naming from the bunyip org instead of the owner was considered and rejected here: it would deepen the existing split where the org switcher shows bunyip's name while emails use mokosh's
tenants.name. Which system owns an organisation's name is still an open product question, noted in the ticket.Verification
Full integration suite: 750 passed, 0 failed.
just checkclean.Six unit tests cover the rule itself (given name wins, blank treated as absent, unusable owner keeps the generic, truncation, trailing-s possessive), plus one integration test that provisions through the real path and reads the row back, so a change to the INSERT cannot quietly restore the constant while the pure function still looks correct.
One caveat worth stating: an earlier full-suite run reported a single failure that I did not capture the name of, and that did not reproduce across two subsequent full runs. I could not identify it, so I am flagging it rather than claiming a clean history.