From 6e9031df1dc90efda8ab0eb8aa526dec8deec256 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 28 Nov 2025 01:37:30 -0500 Subject: Fix web UI bug in search filter This allows Servant's QueryParam Maybe to treat Left as "parameter not provided", so the 'All' filter option (which sends empty string value) now works correctly instead of causing an "Invalid priority" error. Task-Id: t-146 --- Omni/Task/Core.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Omni') diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs index 61a2e83..c469bf8 100644 --- a/Omni/Task/Core.hs +++ b/Omni/Task/Core.hs @@ -162,14 +162,18 @@ instance FromJSON Fact -- HTTP API Instances (for Servant query params) instance FromHttpApiData Status where - parseQueryParam t = case readMaybe (T.unpack t) of - Just s -> Right s - Nothing -> Left ("Invalid status: " <> t) + parseQueryParam t + | T.null t = Left "No status provided" + | otherwise = case readMaybe (T.unpack t) of + Just s -> Right s + Nothing -> Left ("Invalid status: " <> t) instance FromHttpApiData Priority where - parseQueryParam t = case readMaybe (T.unpack t) of - Just p -> Right p - Nothing -> Left ("Invalid priority: " <> t) + parseQueryParam t + | T.null t = Left "No priority provided" + | otherwise = case readMaybe (T.unpack t) of + Just p -> Right p + Nothing -> Left ("Invalid priority: " <> t) -- SQLite Instances -- cgit v1.2.3