feat(data): include tenant_name in the export envelope (PMS-647) #443

Merged
longjacksonle merged 2 commits from feat/PMS-647-export-tenant-name into main 2026-07-10 20:33:04 +02:00

Summary

Adds tenant_name to the tenant data export envelope (GET /api/v1/data/export), next to the existing tenant_id.

Why

POST /api/v1/data/import guards the destructive wipe-and-replace by requiring confirm to equal the target tenant's name. An automated orchestrator that exports a tenant and later re-imports it - specifically Bunyip account backup/restore (BUNYIP-356) - does not otherwise know the Mokosh tenant name. Carrying it in the envelope lets the orchestrator echo it back as confirm without a second lookup round-trip, and keeps the destructive-action guard fully intact.

Notes

  • Additive and backwards-compatible: the import path only reads schema_version + entities and ignores unknown envelope fields, so existing exports/imports are unaffected and schema_version is unchanged.
  • The name is read under the same tenant transaction as the rest of the export.
  • The export/import round-trip integration test now asserts tenant_name is present.

Verification

just pre-commit green (fmt + clippy -D warnings + check + unit + doc). Integration tests compile; the DB round-trip is exercised by CI (integration.yml) - it could not run on the author's box (host port 5433 held by an unrelated container, and the local mokosh Postgres lacked the just dev secret provisioning).

🤖 Generated with Claude Code

## Summary Adds `tenant_name` to the tenant data export envelope (`GET /api/v1/data/export`), next to the existing `tenant_id`. ## Why `POST /api/v1/data/import` guards the destructive wipe-and-replace by requiring `confirm` to equal the target tenant's name. An automated orchestrator that exports a tenant and later re-imports it - specifically Bunyip account backup/restore (BUNYIP-356) - does not otherwise know the Mokosh tenant name. Carrying it in the envelope lets the orchestrator echo it back as `confirm` without a second lookup round-trip, and keeps the destructive-action guard fully intact. ## Notes - Additive and backwards-compatible: the import path only reads `schema_version` + `entities` and ignores unknown envelope fields, so existing exports/imports are unaffected and `schema_version` is unchanged. - The name is read under the same tenant transaction as the rest of the export. - The export/import round-trip integration test now asserts `tenant_name` is present. ## Verification `just pre-commit` green (fmt + clippy `-D warnings` + check + unit + doc). Integration tests compile; the DB round-trip is exercised by CI (`integration.yml`) - it could not run on the author's box (host port 5433 held by an unrelated container, and the local mokosh Postgres lacked the `just dev` secret provisioning). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(data): include tenant_name in the export envelope (PMS-647)
Some checks failed
Check / fmt + clippy + build + tests (pull_request) Successful in 1m30s
Integration / integration tests (pull_request) Successful in 5m40s
E2E / Playwright against staging (pull_request) Failing after 4m5s
d12beadd59
The tenant data export envelope now carries `tenant_name` alongside `tenant_id`. Import's destructive-action guard requires `confirm` to equal the tenant name, so an orchestrator that exports then re-imports (Bunyip account restore, BUNYIP-356) can echo the name straight back from the envelope instead of a second round-trip to look it up. Read under the same tenant transaction as the rest of the export; additive and backwards-compatible (import ignores unknown envelope fields). The round-trip integration test now asserts the field is present.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014gTWMeFYgEAiRKCV3L9jAb
longjacksonle scheduled this pull request to auto merge when all checks succeed 2026-07-10 20:10:00 +02:00
ci: re-trigger checks (E2E flake on shared staging account)
Some checks failed
Check / fmt + clippy + build + tests (pull_request) Successful in 1m39s
E2E / Playwright against staging (pull_request) Failing after 4m5s
Integration / integration tests (pull_request) Successful in 7m24s
Create release / Gate (release-branch merges only) (pull_request) Successful in 0s
Create release / Create release from merged PR (pull_request) Has been skipped
74b50a6c45
No code change. The E2E gate runs Playwright against the live staging deployment (not this PR's SHA) on a single rate-limited shared account, and this PR's run failed transiently while Check + Integration passed and main's E2E is green. Empty commit to re-run.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014gTWMeFYgEAiRKCV3L9jAb
longjacksonle scheduled this pull request to auto merge when all checks succeed 2026-07-10 20:26:01 +02:00
longjacksonle deleted branch feat/PMS-647-export-tenant-name 2026-07-10 20:33:04 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!443
No description provided.