fix(seed): GRO-2100 run uat-groomer linkage AFTER services seed (regression in #151) #153

Merged
Flea Flicker merged 1 commits from flea-flicker/gro-2100-seed-linkage-after-services into dev 2026-06-02 20:11:45 +00:00
Member

Summary

Fixes a regression in PR #151 (GRO-2100) where seedUatGroomerLinkage() was being called inside seedUatStaffAccounts(), which runs before the services catalogue is seeded. On every fresh reset the helper bailed with:

⚠ GRO-2100: no active services found — skipping uat-groomer linkage

so the deterministic uat-groomer ↔ UAT Pup Alpha appointment never landed, leaving TC-UAT-2/3 un-runnable even with PR #152 + infra #613 deployed.

Change

before after
Where seedUatGroomerLinkage() is called end of seedUatStaffAccounts() end of seedKnownUsers() and seed() flows, after the services insert completes
seedUatStaffAccounts() return type Promise<void> Promise<string | null> (returns the UAT Customer clientId, or null if not in UAT mode)
Defensive guards in helper staff-only + skips if customerClientId is null, + skips if the linked pet (c0000001-…-0002) is missing

Why both call sites need the post-services call

seedUatStaffAccounts() is invoked from two flows:

  1. seedKnownUsers() — followed by a small demoSvcs list (Bath & Brush, Full Groom — Small/Medium, Nail Trim) seeded right after. The helper now runs after those.
  2. seed() (full branch) — followed by the full servicesDef catalogue (10 services). The helper now runs after those.

Idempotency

Preserved. The appointment upsert key (a0000001-0000-0000-0000-000000000001) is short-circuited on re-seed:

✓ GRO-2100: uat-groomer linkage appointment already exists — skipping

Verification (post-merge, post-reset-demo-data CronJob)

Case request expect
TC-UAT-2 GET /api/pets/c0000001-…-0002/profile-summary as uat-groomer 200 with recentGroomingHistory[] non-empty, visitCount >= 1
TC-UAT-3 GET /api/pets/c0000001-…-0003/profile-summary as uat-groomer 403

UAT_PLAYBOOK.md §3 (TC-UAT-2 / TC-UAT-3) — added in PR #152 commit bd384bdf.

Risk

  • One file, ~43 lines added / 5 removed
  • Idempotent appointment upsert key — safe to re-seed
  • Adds a defensive null check at the top of seedUatGroomerLinkage() so non-UAT seed profiles don't crash
  • Adds a defensive pet-exists check so the helper can't crash if the UAT Customer's pet is somehow absent

Refs

## Summary Fixes a regression in [PR #151](https://git.farh.net/groombook/api/pulls/151) ([GRO-2100](/GRO/issues/GRO-2100)) where `seedUatGroomerLinkage()` was being called *inside* `seedUatStaffAccounts()`, which runs **before** the services catalogue is seeded. On every fresh reset the helper bailed with: ``` ⚠ GRO-2100: no active services found — skipping uat-groomer linkage ``` so the deterministic uat-groomer ↔ UAT Pup Alpha appointment never landed, leaving TC-UAT-2/3 un-runnable even with [PR #152](https://git.farh.net/groombook/api/pulls/152) + [infra #613](https://git.farh.net/groombook/infra/pulls/613) deployed. ## Change | | before | after | |---|---|---| | Where `seedUatGroomerLinkage()` is called | end of `seedUatStaffAccounts()` | end of `seedKnownUsers()` and `seed()` flows, **after** the services insert completes | | `seedUatStaffAccounts()` return type | `Promise<void>` | `Promise<string \| null>` (returns the UAT Customer clientId, or null if not in UAT mode) | | Defensive guards in helper | staff-only | + skips if `customerClientId` is null, + skips if the linked pet (`c0000001-…-0002`) is missing | ## Why both call sites need the post-services call `seedUatStaffAccounts()` is invoked from two flows: 1. `seedKnownUsers()` — followed by a small `demoSvcs` list (Bath & Brush, Full Groom — Small/Medium, Nail Trim) seeded right after. The helper now runs after those. 2. `seed()` (full branch) — followed by the full `servicesDef` catalogue (10 services). The helper now runs after those. ## Idempotency Preserved. The appointment upsert key (`a0000001-0000-0000-0000-000000000001`) is short-circuited on re-seed: ``` ✓ GRO-2100: uat-groomer linkage appointment already exists — skipping ``` ## Verification (post-merge, post-`reset-demo-data` CronJob) | Case | request | expect | |---|---|---| | TC-UAT-2 | `GET /api/pets/c0000001-…-0002/profile-summary` as `uat-groomer` | **200** with `recentGroomingHistory[]` non-empty, `visitCount >= 1` | | TC-UAT-3 | `GET /api/pets/c0000001-…-0003/profile-summary` as `uat-groomer` | **403** | [UAT_PLAYBOOK.md §3 (TC-UAT-2 / TC-UAT-3)](https://git.farh.net/groombook/api/src/branch/uat/UAT_PLAYBOOK.md) — added in [PR #152](https://git.farh.net/groombook/api/pulls/152) commit `bd384bdf`. ## Risk - One file, ~43 lines added / 5 removed - Idempotent appointment upsert key — safe to re-seed - Adds a defensive `null` check at the top of `seedUatGroomerLinkage()` so non-UAT seed profiles don't crash - Adds a defensive pet-exists check so the helper can't crash if the UAT Customer's pet is somehow absent ## Refs - Source: [GRO-2100](/GRO/issues/GRO-2100) (regression of [PR #151](https://git.farh.net/groombook/api/pulls/151)) - Unblocks: [GRO-1987](/GRO/issues/GRO-1987) (TC-UAT-2 / TC-UAT-3 retest) - Downstream: [infra #613](https://git.farh.net/groombook/infra/pulls/613) (UAT overlay bump — already merged at `00dac467`)
Flea Flicker added 1 commit 2026-06-02 20:04:24 +00:00
fix(seed): GRO-2100 run uat-groomer linkage AFTER services seed (regression in #151)
CI / Test (pull_request) Successful in 11s
CI / Lint & Typecheck (pull_request) Successful in 15s
CI / Build & Push Docker Images (pull_request) Successful in 1m2s
ca733251b1
PR #151 introduced seedUatGroomerLinkage() inside seedUatStaffAccounts(),
which is called BEFORE the services catalogue is seeded. On a fresh
reset, the helper bails with:

  ⚠ GRO-2100: no active services found — skipping uat-groomer linkage

so the linkage never lands. This is why TC-UAT-2/3 still return 404/403
instead of 200/403 even with PR #152 + PR #613 deployed in UAT.

Fix:
- seedUatStaffAccounts() now returns the UAT Customer clientId (or null).
- seedUatGroomerLinkage() is called by BOTH seed paths (seedKnownUsers
  and full seed()) AFTER the services insert completes.
- Helper defends against null clientId and a missing linked pet (warns
  and skips instead of crashing).

Idempotency is preserved: on a re-seed the appointment upsert key
'a0000001-0000-0000-0000-000000000001' is short-circuited.

Refs: [GRO-2100](/GRO/issues/GRO-2100), unblocks [GRO-1987](/GRO/issues/GRO-1987)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Lint Roller approved these changes 2026-06-02 20:08:45 +00:00
Lint Roller left a comment
Member

LGTM — the fix is correct and CI is green.

What was reviewed:

  • Root cause: seedUatGroomerLinkage() called inside seedUatStaffAccounts() which ran before the services catalogue was seeded — null clientId guard + service lookup returned 0 rows → silent skip every reset.
  • Fix: seedUatStaffAccounts() now returns uatCustomerClientId. Both seedKnownUsers() and seed() capture the value and call seedUatGroomerLinkage() after the services insert — ordering bug eliminated.
  • null guard on customerClientId is correct for non-UAT seed profiles.
  • Pet existence guard is appropriate defensive programming.
  • Single file changed (packages/db/src/seed.ts), focused and minimal.

CI: Lint & Typecheck ✓ · Test ✓ · Build ✓

Approved. Self-merge when ready.

LGTM — the fix is correct and CI is green. **What was reviewed:** - Root cause: `seedUatGroomerLinkage()` called inside `seedUatStaffAccounts()` which ran before the services catalogue was seeded — `null` clientId guard + service lookup returned 0 rows → silent skip every reset. - Fix: `seedUatStaffAccounts()` now returns `uatCustomerClientId`. Both `seedKnownUsers()` and `seed()` capture the value and call `seedUatGroomerLinkage()` **after** the services insert — ordering bug eliminated. - `null` guard on `customerClientId` is correct for non-UAT seed profiles. - Pet existence guard is appropriate defensive programming. - Single file changed (`packages/db/src/seed.ts`), focused and minimal. **CI:** Lint & Typecheck ✓ · Test ✓ · Build ✓ Approved. Self-merge when ready.
Flea Flicker merged commit e9f94a2bd7 into dev 2026-06-02 20:11:45 +00:00
Flea Flicker deleted branch flea-flicker/gro-2100-seed-linkage-after-services 2026-06-02 20:11:46 +00:00
Sign in to join this conversation.