Commit 6c3d9ab
Guy Pelletier
fix(preflight): address SITES-48037 review — split null-org from empty-imsOrgId, empty-imsOrgId → 400
@MysticatBot (must-fix): null org and empty imsOrgId are different data-quality
issues with different remediation paths — a null Organization means the site's
FK is dangling (needs data cleanup), while an empty imsOrgId means the org
exists but wasn't fully onboarded (needs config completion). Split into two
distinct branches with distinct log messages and error responses.
@bhellema: `!hasText(imsOrgId)` is now 400 (`PREFLIGHT_INVALID_REQUEST`), not
500. The empty imsOrgId is a config gap that the caller's admin has to
resolve; it isn't a retryable server error. Kept `Organization.findById`
throw (transient DB error) and `Organization not found` (broken FK) as 500
because those are genuinely server-side.
@MysticatBot (non-blocking): cached `site.getOrganizationId()` in `orgId` to
avoid re-calling the getter (and the theoretical re-throw risk in the catch
block if the getter itself fails). Test resilience: swapped
`expect(fetchStub.secondCall).to.be.null` for `expect(fetchStub).to.not.have.been.called`
— cleaner and independent of the HEAD probe's positioning.
Deferred (own follow-ups):
- @johobot: hasAccess(site) already loads the Organization; explore whether
the ORM caches it on the site entity for reuse via site.getOrganization().
Worth verifying caching semantics before threading it through.
- @MysticatBot: callMysticatAnalyze positional-param count. Refactor to
options-object; own PR to keep this one focused.
Tests updated to match:
- "empty imsOrgId" → 400 + PREFLIGHT_INVALID_REQUEST
- "null org" → 500 + "Site organization not found" (distinct message)
- Assertion swap: not.have.been.called instead of secondCall.to.be.null1 parent f3c7325 commit 6c3d9ab
2 files changed
Lines changed: 43 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
537 | 545 | | |
538 | | - | |
539 | | - | |
| 546 | + | |
540 | 547 | | |
541 | | - | |
| 548 | + | |
542 | 549 | | |
543 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
544 | 556 | | |
545 | | - | |
546 | | - | |
| 557 | + | |
| 558 | + | |
547 | 559 | | |
548 | 560 | | |
549 | 561 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1649 | 1649 | | |
1650 | 1650 | | |
1651 | 1651 | | |
1652 | | - | |
1653 | | - | |
1654 | | - | |
1655 | | - | |
1656 | | - | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
1657 | 1657 | | |
1658 | 1658 | | |
1659 | 1659 | | |
| |||
1663 | 1663 | | |
1664 | 1664 | | |
1665 | 1665 | | |
1666 | | - | |
| 1666 | + | |
1667 | 1667 | | |
1668 | | - | |
| 1668 | + | |
1669 | 1669 | | |
1670 | | - | |
1671 | | - | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
1672 | 1675 | | |
1673 | 1676 | | |
1674 | 1677 | | |
| |||
1684 | 1687 | | |
1685 | 1688 | | |
1686 | 1689 | | |
1687 | | - | |
1688 | | - | |
1689 | | - | |
1690 | | - | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
1691 | 1697 | | |
1692 | 1698 | | |
1693 | 1699 | | |
| |||
1697 | 1703 | | |
1698 | 1704 | | |
1699 | 1705 | | |
1700 | | - | |
| 1706 | + | |
1701 | 1707 | | |
1702 | 1708 | | |
1703 | 1709 | | |
| |||
0 commit comments