In a RESTful API how should you handle optional query parameters

I’m currently dealing with a .net API that aims to be RESTful. One of the endpoints I’m working with has two optional query parameters. The following usage is allowed:

/endpoint/search
/endpoint/search?from=01/02/23
/endpoint/search?from=01/02/23&to=01/03/23

This endpoint however returns a 400 when you do not provide a value for these optional query params but the keys still exist. Since I primarily work in JS, having the query params either not exist or have a value of undefined are realistically the same thing this seems odd to me that it would return a 400.

I.e.

/endpoint/search?from=undefined&to=undefined // 400 response

I’ve tried to scour the internet for an answer. I’ve looked into OpenAPI specification and the REST rfc but I can’t find any relevant passages. I’m of the opinion this is making an endpoint overly restrictive and it should handle undefined as a value. What is the correct approach as per spec if possible?