Fix the request root key for reservations_requests create/patch - #148
Merged
Conversation
Core's Api::V3::Reservations::RequestsController calls require_params_for(:reservations_request), which pluralises to `reservations_requests`. Sending `requests` fails the key check and returns 400 Bad Request, so create_reservation_request and patch_reservation_request could never succeed against a real Core. The response root stays `requests` — that is what Core actually emits, and Response#resources_key reads it off the response body, so the two sides legitimately differ. Only the outbound bodies change here.
Robgra13
approved these changes
Aug 10, 2026
Robgra13
left a comment
Contributor
There was a problem hiding this comment.
hand-written from the API design document rather than recorded against a server
that is true, great find
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
create_reservation_requestandpatch_reservation_requestsend the request body under arequestsroot key:Core rejects that.
Api::V3::Reservations::RequestsController#createcallsrequire_params_for(:reservations_request), andrequire_params_forpluralises its argument (resource_name.to_s.pluralize) toreservations_requests. When that key is absent it raisesInvalidPayloadFormatError, which the V3 base controller renders as400 Bad Request.So as released in 1.3.0, neither method can succeed against a real Core — every create and every update 400s.
How it was found
Integrating this endpoint in
bsa-booking(CMB-7366) against a live local Core. We hit the 400 on the first real call and probed both keys directly:requests→ 400,reservations_requests→ 201. The cassette recorded from that run shows the accepted body:Why the existing specs didn't catch it
The cassettes added in #146 look hand-written from the API design document rather than recorded against a server — they carry the doc's example values (
conversation_id: 123,rental_id: 456,client_id: 789,final_price: "950.00"), round timestamps and production URLs. They encode the same assumption as the client code, so the specs agree with the bug rather than catching it.I've corrected the two request bodies in those cassettes to match what Core actually accepts. Their responses are unchanged — see below.
Note on the asymmetry
The request root is
reservations_requests, but Core's response root isrequests. That is not a typo:{"links":{"requests.rental":"..."},"requests":[{"links":{...},"id":60,...}]}Response#resources_keyderives the key from the response body, not from the request, so the two sides are independent and.popkeeps working unchanged. Verified against a live Core response.Changes
create_reservation_request/patch_reservation_requestnow sendreservations_requests: [options]bundle exec rspec spec/bookingsync/api/client/reservations_requests_spec.rb→ 8 examples, 0 failures.Worth flagging for the other channel apps: BSA Airbnb and VRBO integrate the same endpoint and will hit the identical 400.
(Unrelated, noticed while running the suite locally: the specs don't boot on Ruby 3.4 because
base64left the default gems and isn't declared in the Gemfile. I left that out to keep this PR focused.)