From 63ce90b56e4ef73075af034eec09e015b135caed Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Sat, 15 May 2021 00:50:06 +0200 Subject: fix subtle value extraction bug (https://i.imgur.com/tCvZzHo.png) --- skate/map.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'skate') diff --git a/skate/map.go b/skate/map.go index c448848..698725a 100644 --- a/skate/map.go +++ b/skate/map.go @@ -130,7 +130,10 @@ func CreateFixedMapper(field string) Mapper { } f := func(p []byte) ([][]byte, error) { result := gjson.GetBytes(p, field) - key := []byte(result.String()) + // A subtle bug can emerge here: By default we use tab as separator. If + // the value extracted ends with the separator (e.g. tab), then we get + // an invalid row. Hence, trim all space. + key := []byte(strings.TrimSpace(result.String())) return [][]byte{key, p}, nil } return f -- cgit v1.2.3