Skip to content

should not skip should use a default template and send, please fix !!!! - #1011

Merged
JoshuaVSherman merged 2 commits into
devfrom
claude/1250-default-template-fallback
Jul 29, 2026
Merged

should not skip should use a default template and send, please fix !!!!#1011
JoshuaVSherman merged 2 commits into
devfrom
claude/1250-default-template-fallback

Conversation

@JoshuaVSherman

@JoshuaVSherman JoshuaVSherman commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Default template fallback (JaMmusic#1250 root cause): resolvePitch in src/model/outreach/outreach-controller.ts built the template type as body.templateType || venue.templateOverride || venue.venueType, then hard-400'd when all three were empty — that's how 6 of 29 venues silently got skipped in a batch. It now falls back to DEFAULT_TEMPLATE_TYPE (MidRangeCafeBar, per Josh's decision on the issue — the safest pitch for a venue we know nothing about) instead of erroring. Existing precedence is unchanged; the no active template for type ${type} guard is left intact so a missing/inactive default template still fails hard rather than sending garbage.
  • Venue names in the skipped report: sendBatch's skipped entries only carried { venueId, reason }, so the report was unreadable without cross-referencing Mongo ObjectIds by hand. Every skipped entry now also carries venueName — the actual venue name when a venue doc loaded, or the UNKNOWN_VENUE_NAME placeholder ('(unknown venue)') when no venue could be loaded at all (invalid id, venue not found). The field is never omitted.
  • DEFAULT_TEMPLATE_TYPE and UNKNOWN_VENUE_NAME are single exported module-scope constants (no scattered string literals).
  • Out of scope, untouched: venueType tagging/backfill (web-jam-back#843), the dedup guard, the eligibility guard, the kill switch, the email-validity guard.
  • Bumps patch version 2.10.1 -> 2.10.2.

Closes WebJamApps/JaMmusic#1250

How to test locally

Run the full gate:

npm test

Expect: eslint clean, jscpd clean, typecheck clean, all vitest suites green, coverage at/above the 90/90/80/80 gate.

Then exercise the two changes directly against a running server (npm run dev), using curl against POST /outreach/batch (already covered by the unit-test mocks too — see evidence below):

# A venue with no templateType/templateOverride/venueType in the request/venue
# doc now sends instead of being skipped:
curl -i -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"venueIds":["VENUE_ID_NO_TYPE"],"targetDates":"Aug 14-16","targetWeekend":{"start":"2026-09-25","end":"2026-09-27"}}' \
  "$BASE_URL/outreach/batch"
# Expect: sent: 1, skipped: [] (previously this venue landed in skipped with
# "no templateType and venue has no venueType").

# A batch containing an invalid id and a real venue now shows readable names:
curl -i -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"venueIds":["not-an-id","REAL_VENUE_ID"],"targetDates":"Aug 14-16","targetWeekend":{"start":"2026-09-25","end":"2026-09-27"}}' \
  "$BASE_URL/outreach/batch"
# Expect: skipped: [{ venueId: "not-an-id", venueName: "(unknown venue)", reason: "invalid id" }]

Test evidence

Targeted outreach-controller suite:

$ npx vitest run test/unit/outreach/outreach-controller.spec.ts
 RUN  v4.1.5 /home/joshua/WebJamApps/web-jam-back

 Test Files  1 passed (1)
      Tests  213 passed (213)
   Start at  03:01:47
   Duration  839ms (transform 289ms, setup 0ms, import 502ms, tests 208ms, environment 0ms)

Full gate (npm test = eslint + jscpd + typecheck + vitest --coverage), exit 0:

> web-jam-back@2.10.2 test
> eslint ./src && npm run jscpd && npm run typecheck && rimraf coverage && npm run test:unit

...(jscpd: pre-existing clones unrelated to this change, under threshold)...

> web-jam-back@2.10.2 test:unit
> vitest run --coverage

 Test Files  54 passed (54)
      Tests  933 passed (933)
   Start at  03:02:05
   Duration  58.21s (transform 975ms, setup 0ms, import 12.75s, tests 35.69s, environment 6ms)

 % Coverage report from v8
-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------|---------|----------|---------|---------|-------------------
All files          |   93.37 |    87.43 |   88.99 |   94.03 |
 ...model/outreach |   94.12 |    86.82 |   84.21 |   94.13 |
  ...controller.ts |   98.38 |    86.48 |     100 |   99.58 | 205,1514
-------------------|---------|----------|---------|---------|-------------------

=============================== Coverage summary ===============================
Statements   : 93.37% ( 2451/2625 )
Branches     : 87.43% ( 1566/1791 )
Functions    : 88.99% ( 388/436 )
Lines        : 94.03% ( 2034/2163 )
================================================================================

🤖 Work by Claude Code — Sonnet 5

JoshuaVSherman and others added 2 commits July 29, 2026 03:00
JaMmusic#1250 — a 29-pitch batch silently skipped 6 venues with no
venueType/templateOverride/templateType because resolvePitch hard-400'd
instead of sending, and the skip report showed only Mongo ObjectIds so
Josh couldn't tell which venues failed.

- resolvePitch now falls back to DEFAULT_TEMPLATE_TYPE (MidRangeCafeBar,
  per Josh's decision on the issue) instead of erroring when
  templateType/templateOverride/venueType all resolve empty. The
  "no active template" guard still fails hard if even the default is
  missing/inactive.
- Every sendBatch skipped entry now carries venueName (never omitted;
  '(unknown venue)' when no venue doc could be loaded at all).

Bumps patch version 2.10.1 -> 2.10.2.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
JaMmusic#1250 — extends outreach-controller.spec.ts with:
- a venue with no templateType/templateOverride/venueType now resolves
  to DEFAULT_TEMPLATE_TYPE and sends instead of being skipped
- an explicit templateType, and venue.venueType, both still win over
  the default fallback (precedence guardrails)
- every sendBatch skipped entry carries venueName, including the
  UNKNOWN_VENUE_NAME placeholder when no venue doc could be loaded

Full `npm test` (eslint + jscpd + typecheck + vitest --coverage) green:
933/933 tests passing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@JoshuaVSherman
JoshuaVSherman marked this pull request as ready for review July 29, 2026 07:11
@JoshuaVSherman
JoshuaVSherman merged commit 9740193 into dev Jul 29, 2026
2 checks passed
@JoshuaVSherman
JoshuaVSherman deleted the claude/1250-default-template-fallback branch July 29, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

should not skip should use a default template and send, please fix !!!!

1 participant