Skip to content

Commit c8ea784

Browse files
Crawler: limit the error body size
This change prevents storing huge API responses in the error index.
1 parent 8e4bf88 commit c8ea784

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Macroscope/Worker.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Macroscope.Worker (
1313
getStreamOldestEntity,
1414
) where
1515

16+
import Data.Text.Lazy qualified as T
1617
import Data.Vector qualified as V
1718
import Google.Protobuf.Timestamp as Timestamp
1819
import Lentille
@@ -128,7 +129,8 @@ processStream logFunc postFunc = go (0 :: Word) [] []
128129
toCrawlerError (LentilleError ts err) = CrawlerError {..}
129130
where
130131
crawlerErrorCreatedAt = Just $ from ts
131-
(crawlerErrorMessage, crawlerErrorBody) = case err of
132+
crawlerErrorBody = T.take 4096 crawlerErrorBody'
133+
(crawlerErrorMessage, crawlerErrorBody') = case err of
132134
DecodeError xs -> ("decode", encodeJSON xs)
133135
RequestError e -> ("graph", encodeJSON e)
134136
RateLimitInfoError e -> ("rate-limit-info", encodeJSON e)

0 commit comments

Comments
 (0)