Skip to content

fix(booking): PROJ-1652 hydrate_parents with no parent ids - #335

Merged
camreeves merged 1 commit into
masterfrom
PROJ-1652-hydrate-parents-no-parents
Oct 16, 2026
Merged

camreeves merged 1 commit into
masterfrom
PROJ-1652-hydrate-parents-no-parents

Conversation

@camreeves

Copy link
Copy Markdown
Contributor

What was broken

Booking.hydrate_parents always ran Booking.where(id: parent_ids). When none of the bookings has a parent_id that list is empty, pg-orm renders id IN (), and Postgres answers syntax error at or near ")".

staff-api calls it for any non-empty result when include_parent_bookings=true. Concierge's Assets page sends that with type=asset-request, and asset requests linked to a meeting have no parent booking, so the list answers 500 (PROJ-1652, seen on Nestle).

Reproduced on placeos-dev on 16 Oct: the same bookings query returns 200 without include_parent_bookings and 500 with it.

Change

Return the bookings unchanged when there are no parent ids to load.

Tests

New spec hydrate_parents returns bookings that have no parent unchanged. Run with spec/tenant_spec.cr spec/booking_spec.cr on a fresh database:

  • before the fix: 42 examples, 1 error, syntax error at or near ")" (PQ::PQError)
  • after the fix: 42 examples, 0 failures

booking_spec.cr on its own errors on every Generator.tenant call, because the tenants table is only cleared by another file's global before_each. That is unrelated to this change.

After merge

staff-api needs a models release and a shard bump to pick this up.

🤖 Generated with Claude Code

Booking.hydrate_parents queried `id IN ()` when none of the bookings had a
parent_id, which Postgres rejects as a syntax error. staff-api calls it for
every non-empty result when include_parent_bookings=true, so Concierge's
asset request list (type=asset-request, parentless bookings) answered 500.

Return the bookings unchanged when there are no parent ids to load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the type: bug something isn't working label Oct 15, 2026
@camreeves
camreeves merged commit efef18b into master Oct 16, 2026
8 checks passed
@camreeves
camreeves deleted the PROJ-1652-hydrate-parents-no-parents branch October 16, 2026 00:55
camreeves added a commit to PlaceOS/staff-api that referenced this pull request Oct 16, 2026
9.119.6 is 9.119.5 plus PlaceOS/models#335: Booking.hydrate_parents no longer
runs `id IN ()` when no booking in the page has a parent, which made
Concierge asset requests return a 500.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant