diff --git a/CHANGELOG b/CHANGELOG index b28b46ca..876fd078 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +Version 3.1.1 (2025-01-23) +-------------------------- +Fix GTMSS preview expired message handling + Version 3.1.0 (2025-01-20) -------------------------- Change License to SLULA 1.1 diff --git a/README.md b/README.md index 7a72b455..c0745172 100644 --- a/README.md +++ b/README.md @@ -18,5 +18,5 @@ The AWS-specific distribution contains everything, including the Kinesis source, To comply with the [Amazon Software License](https://github.com/twitchscience/kinsumer/blob/master/LICENSE), you may only use this distribution of Snowbridge _“with the web services, computing platforms or applications provided by Amazon.com, Inc. or its affiliates, including Amazon Web Services, Inc.”_ -[release-image]: http://img.shields.io/badge/golang-3.1.0-6ad7e5.svg?style=flat +[release-image]: http://img.shields.io/badge/golang-3.1.1-6ad7e5.svg?style=flat [releases]: https://github.com/snowplow/snowbridge/releases/ diff --git a/VERSION b/VERSION index fd2a0186..94ff29cc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.0 +3.1.1 diff --git a/cmd/constants.go b/cmd/constants.go index 6dc59f5e..d5cda466 100644 --- a/cmd/constants.go +++ b/cmd/constants.go @@ -13,7 +13,7 @@ package cmd const ( // AppVersion is the current version of the app - AppVersion = "3.1.0" + AppVersion = "3.1.1" // AppName is the name of the application to use in logging / places that require the artifact AppName = "snowbridge" diff --git a/pkg/transform/snowplow_gtmss_preview.go b/pkg/transform/snowplow_gtmss_preview.go index e2556dd4..8c6dfbe8 100644 --- a/pkg/transform/snowplow_gtmss_preview.go +++ b/pkg/transform/snowplow_gtmss_preview.go @@ -77,25 +77,26 @@ func gtmssPreviewTransformation(ctx, property, headerKey string, expiry time.Dur return nil, nil, message, nil } - tstamp, err := parsedEvent.GetValue("collector_tstamp") + headerVal, err := extractHeaderValue(parsedEvent, ctx, property) if err != nil { message.SetError(err) return nil, nil, message, nil } - if collectorTstamp, ok := tstamp.(time.Time); ok { - if time.Now().UTC().After(collectorTstamp.Add(expiry)) { - message.SetError(errors.New("Message has expired")) + if headerVal != nil { + tstamp, err := parsedEvent.GetValue("collector_tstamp") + if err != nil { + message.SetError(err) return nil, nil, message, nil } - } - headerVal, err := extractHeaderValue(parsedEvent, ctx, property) - if err != nil { - message.SetError(err) - return nil, nil, message, nil - } - if headerVal != nil { + if collectorTstamp, ok := tstamp.(time.Time); ok { + if time.Now().UTC().After(collectorTstamp.Add(expiry)) { + message.SetError(errors.New("Message has expired")) + return nil, nil, message, nil + } + } + if message.HTTPHeaders == nil { message.HTTPHeaders = make(map[string]string) } diff --git a/pkg/transform/snowplow_gtmss_preview_test.go b/pkg/transform/snowplow_gtmss_preview_test.go index 02b8c832..ffcd160a 100644 --- a/pkg/transform/snowplow_gtmss_preview_test.go +++ b/pkg/transform/snowplow_gtmss_preview_test.go @@ -69,7 +69,7 @@ func TestGTMSSPreview(t *testing.T) { Ctx: "contexts_com_google_tag-manager_server-side_preview_mode_1", Property: "x-gtm-server-preview", HeaderKey: "x-gtm-server-preview", - Expiry: fiftyYears, + Expiry: 1 * time.Hour, InputMsg: &models.Message{ Data: spTsvNoGtmss, PartitionKey: "pk",