Skip to content

Commit

Permalink
1421 update logs for Unicode Nul character
Browse files Browse the repository at this point in the history
  • Loading branch information
Cmdv committed May 10, 2024
1 parent fbe13d0 commit 6b97cc0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Expand Up @@ -88,7 +88,7 @@ insertRedeemerData tracer txId txd = do
case mRedeemerDataId of
Just redeemerDataId -> pure redeemerDataId
Nothing -> do
value <- safeDecodeToJson tracer "insertRedeemerData" $ Generic.txDataValue txd
value <- safeDecodeToJson tracer "insertDatum: Column 'value' in table 'datum' " $ Generic.txDataValue txd
lift
. DB.insertRedeemerData
$ DB.RedeemerData
Expand All @@ -113,7 +113,7 @@ insertDatum tracer cache txId txd = do
case mDatumId of
Just datumId -> pure datumId
Nothing -> do
value <- safeDecodeToJson tracer "insertDatum" $ Generic.txDataValue txd
value <- safeDecodeToJson tracer "insertRedeemerData: Column 'value' in table 'redeemer' " $ Generic.txDataValue txd
lift $
insertDatumAndCache cache (Generic.txDataHash txd) $
DB.Datum
Expand Down Expand Up @@ -203,7 +203,7 @@ insertScript tracer txId script = do
where
scriptConvert :: MonadIO m => Generic.TxScript -> m (Maybe Text)
scriptConvert s =
maybe (pure Nothing) (safeDecodeToJson tracer "insertScript") (Generic.txScriptJson s)
maybe (pure Nothing) (safeDecodeToJson tracer "insertScript: Column 'json' in table 'script' ") (Generic.txScriptJson s)

insertExtraKeyWitness ::
(MonadBaseControl IO m, MonadIO m) =>
Expand Down
Expand Up @@ -260,7 +260,7 @@ insertTxMetadata tracer txId inOpts mmetadata = do
mkDbTxMetadata (key, md) = do
let jsonbs = LBS.toStrict $ Aeson.encode (metadataValueToJsonNoSchema md)
singleKeyCBORMetadata = serialiseTxMetadataToCbor $ Map.singleton key md
mjson <- safeDecodeToJson tracer "insertTxMetadata" jsonbs
mjson <- safeDecodeToJson tracer "prepareTxMetadata: Column 'json' in table 'metadata' " jsonbs
pure $
Just $
DB.TxMetadata
Expand Down
2 changes: 1 addition & 1 deletion cardano-db-sync/src/Cardano/DbSync/Era/Util.hs
Expand Up @@ -47,6 +47,6 @@ safeDecodeToJson tracer tracePrefix x = do
-- See https://github.com/IntersectMBO/cardano-db-sync/issues/297
if containsUnicodeNul json
then do
liftIO $ logWarning tracer $ tracePrefix <> ": dropped due to a Unicode NUL character. " <> json
liftIO $ logWarning tracer $ tracePrefix <> "was recorded as null, due to a Unicode NUL character found when trying to parse the json."
pure Nothing
else pure $ Just json

0 comments on commit 6b97cc0

Please sign in to comment.