@@ -49,9 +49,11 @@ const VALID_ENDPOINTS = [
4949const ALL_METHODS = [ "GET" , "POST" , "PUT" , "DELETE" , "PATCH" , "HEAD" , "OPTIONS" ] ;
5050
5151/**
52- * Generates a valid UUID-like booking ID for parameterized routes.
52+ * Generates a valid UUID v4 booking ID for parameterized routes. Constrained
53+ * to v4 because `handlers.ts` BOOKING_ID_REGEX only accepts v4 (matching
54+ * what Aurora DSQL's `gen_random_uuid()` emits).
5355 */
54- const bookingIdArb = fc . uuid ( ) ;
56+ const bookingIdArb = fc . uuid ( { version : 4 } ) ;
5557
5658/**
5759 * Generates a random path that does NOT match any booking endpoint.
@@ -161,6 +163,41 @@ Deno.test("property: wrong method on valid path returns 404", async () => {
161163 ) ;
162164} ) ;
163165
166+ Deno . test ( "property: non-v4 UUID shapes on /bookings/:id return 404" , async ( ) => {
167+ // The router's BOOKING_ID_REGEX enforces UUID v4 (third group starts with
168+ // `4`, fourth with `[89ab]`). Aurora DSQL's gen_random_uuid() always emits
169+ // v4, so anything else is malformed input and is rejected upstream without
170+ // touching the DB. This property covers v1/v3/v5 and the NIL UUID.
171+ const nonV4UuidArb = fc . oneof (
172+ fc . uuid ( { version : 1 } ) ,
173+ fc . uuid ( { version : 3 } ) ,
174+ fc . uuid ( { version : 5 } ) ,
175+ fc . constant ( "00000000-0000-0000-0000-000000000000" ) ,
176+ ) ;
177+
178+ await fc . assert (
179+ fc . asyncProperty (
180+ fc . constantFrom ( "GET" , "PUT" , "DELETE" ) ,
181+ nonV4UuidArb ,
182+ async ( method , id ) => {
183+ const opts : RequestInit = { method } ;
184+ if ( method === "PUT" ) {
185+ opts . body = JSON . stringify ( { booked_by : "test" } ) ;
186+ opts . headers = { "Content-Type" : "application/json" } ;
187+ }
188+
189+ const req = new Request ( `http://localhost:8000/bookings/${ id } ` , opts ) ;
190+ const res = await handleRequest ( req , CTX ) ;
191+ assertEquals ( res . status , 404 ) ;
192+
193+ const body = await res . json ( ) ;
194+ assertEquals ( body . error , "Not Found" ) ;
195+ } ,
196+ ) ,
197+ { numRuns : 50 } ,
198+ ) ;
199+ } ) ;
200+
164201Deno . test ( "property: jsonResponse always produces valid JSON with correct content-type" , ( ) => {
165202 fc . assert (
166203 fc . property (
0 commit comments