Skip to content

Commit 7118fd8

Browse files
authored
strip all null bytes from utf8 strings that come from substreams, like it's done on other sources (#4328)
1 parent af4f653 commit 7118fd8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

chain/substreams/src/trigger.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,15 @@ fn decode_value(value: &crate::codec::value::Typed) -> Result<Value, MappingErro
257257
.map(Value::BigInt)
258258
.map_err(|err| MappingError::Unknown(anyhow::Error::from(err))),
259259

260-
Typed::String(new_value) => Ok(Value::String(new_value.clone())),
260+
Typed::String(new_value) => {
261+
let mut string = new_value.clone();
262+
263+
// Strip null characters since they are not accepted by Postgres.
264+
if string.contains('\u{0000}') {
265+
string = string.replace('\u{0000}', "");
266+
}
267+
Ok(Value::String(string))
268+
}
261269

262270
Typed::Bytes(new_value) => base64::decode(&new_value)
263271
.map(|bs| Value::Bytes(Bytes::from(bs.as_ref())))

0 commit comments

Comments
 (0)