Skip to content

Gig create/update rejects venue-linked gigs (Invalid create gig data) #256

Description

@JoshuaVSherman

Blocks WebJamApps/JaMmusic#1254 "cannot create new gig error needs fixing immediately!" — Josh cannot post a newly booked gig. Production defect, both repos already on main.

Why

Since JaM's 3-path venue picker shipped, the "Pick Existing Venue" path sends venueId and deliberately sends empty strings for the legacy free-text fields (JaMmusic/src/containers/Music/Gigs/CreateGigDialog.tsx:65-76 passes '' for city and usState as literals; venue is only ever populated by the "No Venue (one-off)" editor).

This server still hard-requires those legacy fields, so every venue-linked gig is rejected:

  • src/AgController/index.ts:272if (gig && gig.datetime && gig.city && gig.usState && gig.venue) → else Invalid create gig data. This is the error Josh sees.
  • src/AgController/index.ts:308updateGig has the identical check (Invalid gig data), and JaMmusic/src/containers/Music/Gigs/EditGigDialog.tsx:101-105 hardcodes city:''/usState:'' on every save, so editing a venue-linked gig is broken the same way — create just fails first.
  • src/model/gig/gig-schema.ts:16venue: { type: String, required: true }. Even with the two checks relaxed, Mongoose rejects a venue-linked gig that has no free-text venue.

city/usState/venue are vestigial for the linked path: every consumer already resolves display values through the populated venue (JaMmusic/src/containers/Music/Gigs/gigs.utils.tsx:226-231, Gigs/index.tsx:26-55).

Scope

  1. newGig (src/AgController/index.ts:272) — accept a gig when it has datetime AND (venueId OR a non-empty venue). Drop city/usState from the requirement entirely; they are display-only legacy and are resolved from the linked venue. Keep the same socketError/Invalid create gig data message shape on genuine failures.
  2. updateGig (src/AgController/index.ts:308) — same rule, same reasoning. Keep the #253 rethrow behavior exactly as it is.
  3. src/model/gig/gig-schema.ts:16venue becomes required: false. A gig is now identified by venueId OR venue; neither alone is mandatory at the schema layer, and the handler above is the gate.
  4. Unit tests in test/AgController/index.spec.ts covering, for both create and update: venue-linked payload (venueId set, venue/city/usState empty) → succeeds; one-off payload (venue set, no venueId) → succeeds; neither venueId nor venue → still rejected with the existing message; missing datetime → still rejected.

Non-goals

  • No change to the legacy newTour/editTour message-name tolerance — it keeps working as-is.
  • No JaM/frontend changes. The companion frontend fix (EditGigDialog wiping city/usState on legacy gigs) is EditGigDialog wipes city/usState on one-off (no-venue) gigs JaMmusic#1275 "EditGigDialog wipes city/usState on one-off (no-venue) gigs" and is independent of this issue — neither blocks the other.
  • No data migration and no backfill of venueId onto old gigs.
  • web-jam-back/src/model/gig/gig-schema.ts:22 carries the same venue: required: true, but that process never creates gigs (gig-router.ts exposes only /:id/announce plus byId, and findByIdAndUpdate does not run validators by default), so it is dormant. Leave it alone here; a separate alignment issue can pick it up if it ever bites.

Acceptance criteria

  • Creating a gig with only datetime + venueId succeeds and publishes gigCreated.
  • Editing that gig with city/usState empty succeeds and publishes gigUpdated.
  • A one-off gig (free-text venue, no venueId) still creates and updates.
  • A payload with neither venueId nor venue still transmits socketError.
  • Full npm test green (lint + typecheck + coverage), not sub-scripts. Coverage gate stays at or above its current level.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions