Skip to content

Commit c2066ad

Browse files
authored
fix(bigquery): sanitize unicode null sequence (#382)
* fix(bigquery): sanitize unicode sequence * chore: add makefile lint target
1 parent 9155e4f commit c2066ad

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,7 @@ generate-proto: ## regenerate protos
3535
@echo " > cloning protobuf from odpf/proton"
3636
@echo " > generating protobuf"
3737
@buf generate --template buf.gen.yaml https://github.com/odpf/proton/archive/a0bc6dbf2ad91abfebc4bf5f70e275983109baca.zip#strip_components=1 --path odpf/assets
38-
@echo " > protobuf compilation finished"
38+
@echo " > protobuf compilation finished"
39+
40+
lint: ## Lint with golangci-lint
41+
golangci-lint run

plugins/extractors/bigquery/bigquery.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ func (e *Extractor) buildPreview(ctx context.Context, t *bigquery.Table) (previe
312312
err = errors.Wrapf(err, "error marshalling \"%s\" to json", t.FullyQualifiedName())
313313
return
314314
}
315+
// sanitize unicode sequence
316+
// replace unicode null characters with "null" string to ensure downstream would not have issues dealing with unicode null characters
317+
jsonString := strings.ReplaceAll(string(jsonBytes), "\\u0000", "null")
318+
jsonBytes = []byte(jsonString)
315319
err = json.Unmarshal(jsonBytes, &temp)
316320
if err != nil {
317321
err = errors.Wrapf(err, "error marshalling \"%s\" to json", t.FullyQualifiedName())

0 commit comments

Comments
 (0)