Hello,
I noticed that when submitting invalid request parameters to the rest api - like invalid datetime (starttime=2025-10-26T07:34:71.502Z) the server throws 500 - Internal Server Error.
I think it would be better to throw 400 - Bad Request in order to help the user resolve the issue faster and easier.
I can make a pull request with
--- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/JSONResponseExceptionMapper.java
+++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/JSONResponseExceptionMapper.java
@@ -13,6 +13,7 @@
package org.openhab.core.io.rest.core.internal;
import java.io.IOException;
+import java.lang.IllegalArgumentException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
@@ -50,6 +51,9 @@ public class JSONResponseExceptionMapper implements ExceptionMapper<Exception> {
logger.debug("Failed writing HTTP response, since other side closed the connection", e);
// Returning null results in a Response.Status.NO_CONTENT response.
return null;
+ } else if (e instanceof IllegalArgumentException){
+ logger.debug("Iivalid argument submitted for REST request", e);
+ return JSONResponse.createErrorResponse(Response.Status.BAD_REQUEST, e.getMessage());
} else {
logger.error("Unexpected exception occurred while processing REST request.", e);
return delegate.toResponse(e);
What are your thoughts on this change?