From ac765646a58bbb3bd48841d36bdafe669a6c87fe Mon Sep 17 00:00:00 2001 From: Aubrey Tatarowicz Date: Thu, 22 Feb 2024 16:38:06 -0600 Subject: [PATCH] We should enforce these required inputs by returning a useful error and 400 response. right now it is 500 --- .../com/slack/kaldb/elasticsearchApi/OpenSearchRequest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kaldb/src/main/java/com/slack/kaldb/elasticsearchApi/OpenSearchRequest.java b/kaldb/src/main/java/com/slack/kaldb/elasticsearchApi/OpenSearchRequest.java index fa2de9f7f4..e6dff69df9 100644 --- a/kaldb/src/main/java/com/slack/kaldb/elasticsearchApi/OpenSearchRequest.java +++ b/kaldb/src/main/java/com/slack/kaldb/elasticsearchApi/OpenSearchRequest.java @@ -85,14 +85,20 @@ private static String getQueryString(JsonNode body) { return queryString; } + // This is required. consider returning a more useful error to the user than 500 + // or setting a reasonable default (default seems a good option here) private static int getHowMany(JsonNode body) { return body.get("size").asInt(); } + // This is required. consider returning a more useful error to the user than 500 + // or setting a reasonable default (not sure what that would be) private static long getStartTimeEpochMs(JsonNode body) { return body.get("query").findValue("gte").asLong(); } + // This is required. consider returning a more useful error to the user than 500 + // or setting a reasonable default (not sure what that would be) private static long getEndTimeEpochMs(JsonNode body) { return body.get("query").findValue("lte").asLong(); }