diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-28 01:37:30 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-28 01:37:30 -0500 |
| commit | 6e9031df1dc90efda8ab0eb8aa526dec8deec256 (patch) | |
| tree | a92c541f61f056fdabd85769224d7ccbfe819663 /Omni/Task | |
| parent | c3f48a938af0b9a2f692fab2168cc549d629511c (diff) | |
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
Diffstat (limited to 'Omni/Task')
| -rw-r--r-- | Omni/Task/Core.hs | 16 |
1 files changed, 10 insertions, 6 deletions
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 |
