From 4e8bae613c9331084e16966c43588b8bacbc6828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Thu, 23 Jan 2025 11:25:04 +0100 Subject: [PATCH 1/2] Fix GTMSS preview expired message handling So that only messages with provided preview context can expire. If there is no context, message never expires and is simply passed through. --- pkg/transform/snowplow_gtmss_preview.go | 23 ++++++++++---------- pkg/transform/snowplow_gtmss_preview_test.go | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/pkg/transform/snowplow_gtmss_preview.go b/pkg/transform/snowplow_gtmss_preview.go index 9eaf0e9b..b17975da 100644 --- a/pkg/transform/snowplow_gtmss_preview.go +++ b/pkg/transform/snowplow_gtmss_preview.go @@ -66,25 +66,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 3def4d57..715968ca 100644 --- a/pkg/transform/snowplow_gtmss_preview_test.go +++ b/pkg/transform/snowplow_gtmss_preview_test.go @@ -59,7 +59,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", From 3ae727961e32ba04e1f777abcac213cf061d664d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Thu, 23 Jan 2025 12:29:18 +0100 Subject: [PATCH 2/2] Prepare for 3.0.1 release --- CHANGELOG | 4 ++++ README.md | 2 +- VERSION | 2 +- cmd/constants.go | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 56d29cba..9ce311c0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +Version 3.0.1 (2025-01-23) +-------------------------- +Fix GTMSS preview expired message handling + Version 3.0.0 (2024-11-06) -------------------------- Ensure all timestamps used in reporting are UTC diff --git a/README.md b/README.md index 918e2e08..b6d8796b 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.0.0-6ad7e5.svg?style=flat +[release-image]: http://img.shields.io/badge/golang-3.0.1-6ad7e5.svg?style=flat [releases]: https://github.com/snowplow/snowbridge/releases/ diff --git a/VERSION b/VERSION index 4a36342f..cb2b00e4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.0 +3.0.1 diff --git a/cmd/constants.go b/cmd/constants.go index 511247bc..8d3631c2 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.0.0" + AppVersion = "3.0.1" // AppName is the name of the application to use in logging / places that require the artifact AppName = "snowbridge"