You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Booking sample answers 500 for a null or missing stay #465
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
Merge pull request #467 from CaffeinatedCoder/fix/465-sample-null-stay
Merge pull request #469 from CaffeinatedCoder/fix/465-sample-null-sta…