Skip to content

Booking sample answers 500 for a null or missing stay #465

Closed

Description

@CaffeinatedCoder

Found by an outside pre-tag review of release/10.x at 15085f9.

Problem

POST /bookings with {"roomId":1,"guest":"Ada","stay":null}, or with no stay at all, binds BookingRequest.Stay as null, because System.Text.Json doesn't enforce nullable annotations by default. CheckStay then reaches its throwing discard arm, and the sample answers 500 with an UnreachableException instead of 400 with a validation problem. docs/walkthrough.md quotes CheckStay and says the discard arm is only there for the compiler. That isn't true while null can reach it.

Expected

A missing or null stay is a validation error: a 400 with {"stay":["…"]}, like the other bad stays.

Done when

  • CheckStay handles null before the shapes. The walkthrough quotes the new code and says why null can arrive.
  • WalkthroughSampleTests posts a null stay and a missing stay and expects the 400. The test is proven by reverting the fix.
  • The fix lands on main and is cherry-picked into release/10.x. The sample isn't in a package, so it needs no changelog row.

Activity

  1. added this to the 10.3.0 milestone on Oct 25, 2026
  2. added
    bugSomething isn't working
    severity/lowCosmetic, message or documentation-level difference
    on Oct 25, 2026
  3. added a commit that references this issue on Oct 25, 2026
  4. added a commit that references this issue on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingseverity/lowCosmetic, message or documentation-level difference

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions