Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: warehouse transformations for tracking plans #5662

Merged
merged 1 commit into from
Mar 28, 2025

Conversation

achettyiitr
Copy link
Member

@achettyiitr achettyiitr commented Mar 28, 2025

Description

The Tracking Plan properties in the Go code differ in type from the response received from rudder-transformer, causing a type mismatch:

  • context_tracking_plan_version:
    • Unmarshalling response from rudder-transformer treats all numbers as json.Number (essentially float64).
    • Go code sets it as int.
  • context_violation_errors:
    • Unmarshalling response from rudder-transformer returns it as []any.
    • Go code sets it as []types.ValidationError.
  • This results in a type mismatch, though the actual data remains correct.
 - 			"context_tracking_plan_version": int(8),
 + 			"context_tracking_plan_version": float64(8),
 - 			"context_violation_errors": []types.ValidationError{
 - 				{
 - 					Type:     "Required-Missing",
 - 					Message:  "must have required property 'name'",
 - 					Meta:     map[string]string{"instancePath": "/traits", "schemaPath": "#/properties/traits/required"},
 - 					Property: "name",
 - 				},
 - 				{
 - 					Type:    "Datatype-Mismatch",
 - 					Message: "must be string",
 - 					Meta: map[string]string{
 - 						"instancePath": "/traits/email",
 - 						"schemaPath":   "#/properties/traits/properties/e"...,
 - 					},
 - 				},
 - 			},
 + 			"context_violation_errors": []any{
 + 				map[string]any{
 + 					"message": string("must have required property 'name'"),
 + 					"meta": map[string]any{
 + 						"instancePath": string("/traits"),
 + 						"schemaPath":   string("#/properties/traits/required"),
 + 					},
 + 					"property": string("name"),
 + 					"type":     string("Required-Missing"),
 + 				},
 + 				map[string]any{
 + 					"message": string("must be string"),
 + 					"meta": map[string]any{
 + 						"instancePath": string("/traits/email"),
 + 						"schemaPath":   string("#/properties/traits/properties/e"...),
 + 					},
 + 					"property": string(""),
 + 					"type":     string("Datatype-Mismatch"),
 + 				},
 + 			},

Linear Ticket

  • Resolves WAR-424

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Copy link

codecov bot commented Mar 28, 2025

Codecov Report

Attention: Patch coverage is 53.48837% with 20 lines in your changes missing coverage. Please review.

Project coverage is 77.02%. Comparing base (5019422) to head (7fce04b).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
warehouse/transformer/datatype.go 39.39% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5662      +/-   ##
==========================================
- Coverage   77.11%   77.02%   -0.10%     
==========================================
  Files         476      476              
  Lines       65613    65654      +41     
==========================================
- Hits        50598    50567      -31     
- Misses      12248    12319      +71     
- Partials     2767     2768       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@achettyiitr achettyiitr force-pushed the fix.warehouse-transformer-tracking-plan branch from b3e5385 to 7fce04b Compare March 28, 2025 07:35
@achettyiitr achettyiitr merged commit 3692063 into master Mar 28, 2025
58 checks passed
@achettyiitr achettyiitr deleted the fix.warehouse-transformer-tracking-plan branch March 28, 2025 13:51
Message string
Meta map[string]string
Property string
}(types.ValidationError{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why such compile-time check is necessary for this struct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, we are relying on this struct to do the conversion from map[string]string to map[string]any. In case if something changes in future, we need to aware of it like they added new fields or modified some fields. If we don't do that it would break.

func convertToSliceIfViolationErrors(val any) any {
	if validationErrors, ok := val.([]types.ValidationError); ok {
		result := make([]any, len(validationErrors))
		for i, e := range validationErrors {
			result[i] = map[string]any{
				"type":     e.Type,
				"message":  e.Message,
				"meta":     lo.MapValues(e.Meta, func(value, _ string) any { return value }),
				"property": e.Property,
			}
		}
		return result
	}
	return val
}

This was referenced Apr 1, 2025
satishrudderstack pushed a commit that referenced this pull request Apr 1, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.46.0-rc.1](v1.45.0...v1.46.0-rc.1)
(2025-04-01)


### Features

* introduce workers per partition in processor
([#5607](#5607))
([46d61b0](46d61b0))
* move async batch router destinations to use OAuth v2 flow
([#5574](#5574))
([3e35b23](3e35b23))
* option for disabling view creation for bigquery
([#5630](#5630))
([c804547](c804547))
* **processor:** break down transformations step
([#5639](#5639))
([379fcbd](379fcbd))
* **processor:** count pending events without blocking
([#5605](#5605))
([a41c63d](a41c63d))


### Bug Fixes

* compilation error in events_test.go
([#5671](#5671))
([e3ead37](e3ead37))
* increased archival table count alert firing after starting using
dslimit
([#5649](#5649))
([ff799d4](ff799d4))
* remove the noisy combination for version deprecation detection
([#5629](#5629))
([4516a40](4516a40))
* sonnet panic while unmarshalling float64 types
([#5616](#5616))
([c1236e4](c1236e4))
* warehouse transformations for data_warehouse json paths
([#5653](#5653))
([2bbe140](2bbe140))
* warehouse transformations for mandatory fields
([#5658](#5658))
([5019422](5019422))
* warehouse transformations for tracking plans
([#5662](#5662))
([3692063](3692063))


### Miscellaneous

* add limiter to pretransform
([#5622](#5622))
([57ba242](57ba242))
* badger configuration tuning
([#5634](#5634))
([1936b98](1936b98))
* bump sqlconnect-go to 1.18.1
([#5635](#5635))
([f4d78bf](f4d78bf))
* dedup service improvements
([#5602](#5602))
([2e7497e](2e7497e))
* **deps:** bump docker/login-action from 3.3.0 to 3.4.0
([#5604](#5604))
([7e5cea3](7e5cea3))
* **deps:** bump github.com/golang-jwt/jwt/v5 from 5.2.1 to 5.2.2 in the
go_modules group
([#5643](#5643))
([4510413](4510413))
* **deps:** bump golangci/golangci-lint-action from 6 to 7
([#5641](#5641))
([1110b6a](1110b6a))
* **deps:** bump the go-deps group across 1 directory with 5 updates
([#5633](#5633))
([a5a8978](a5a8978))
* **deps:** bump the go-deps group across 1 directory with 5 updates
([#5642](#5642))
([89070bd](89070bd))
* migrate sample event column to text for reporting
([#5503](#5503))
([7d6cbf9](7d6cbf9))
* optimise schema generation function
([#5597](#5597))
([f1818d0](f1818d0))
* remove transformations v2 flag
([#5650](#5650))
([3182f9a](3182f9a))
* sync release v1.45.0 to main branch
([#5617](#5617))
([3669407](3669407))
* use rss for calculating used memory in adaptive payload limiter
([#5656](#5656))
([63ff163](63ff163))
* use sonnet as the default json library
([#5657](#5657))
([4c6e5e0](4c6e5e0))
* version deprecation detection avoid regex
([#5625](#5625))
([0d0e7dd](0d0e7dd))
* version deprecation detection logic
([#5644](#5644))
([345162a](345162a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
This was referenced Apr 1, 2025
atzoum pushed a commit that referenced this pull request Apr 1, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.46.0-rc.2](v1.45.0...v1.46.0-rc.2)
(2025-04-01)


### Features

* introduce workers per partition in processor
([#5607](#5607))
([46d61b0](46d61b0))
* move async batch router destinations to use OAuth v2 flow
([#5574](#5574))
([3e35b23](3e35b23))
* option for disabling view creation for bigquery
([#5630](#5630))
([c804547](c804547))
* **processor:** break down transformations step
([#5639](#5639))
([379fcbd](379fcbd))
* **processor:** count pending events without blocking
([#5605](#5605))
([a41c63d](a41c63d))


### Bug Fixes

* compilation error in events_test.go
([#5671](#5671))
([e3ead37](e3ead37))
* increased archival table count alert firing after starting using
dslimit
([#5649](#5649))
([ff799d4](ff799d4))
* remove the noisy combination for version deprecation detection
([#5629](#5629))
([4516a40](4516a40))
* sonnet panic while unmarshalling float64 types
([#5616](#5616))
([c1236e4](c1236e4))
* warehouse transformations for data_warehouse json paths
([#5653](#5653))
([2bbe140](2bbe140))
* warehouse transformations for mandatory fields
([#5658](#5658))
([5019422](5019422))
* warehouse transformations for tracking plans
([#5662](#5662))
([3692063](3692063))


### Miscellaneous

* add limiter to pretransform
([#5622](#5622))
([57ba242](57ba242))
* badger configuration tuning
([#5634](#5634))
([1936b98](1936b98))
* bump sqlconnect-go to 1.18.1
([#5635](#5635))
([f4d78bf](f4d78bf))
* dedup service improvements
([#5602](#5602))
([2e7497e](2e7497e))
* **deps:** bump docker/login-action from 3.3.0 to 3.4.0
([#5604](#5604))
([7e5cea3](7e5cea3))
* **deps:** bump github.com/golang-jwt/jwt/v5 from 5.2.1 to 5.2.2 in the
go_modules group
([#5643](#5643))
([4510413](4510413))
* **deps:** bump golangci/golangci-lint-action from 6 to 7
([#5641](#5641))
([1110b6a](1110b6a))
* **deps:** bump the go-deps group across 1 directory with 5 updates
([#5633](#5633))
([a5a8978](a5a8978))
* **deps:** bump the go-deps group across 1 directory with 5 updates
([#5642](#5642))
([89070bd](89070bd))
* increase max idle connections per host for kinesis
([#5652](#5652))
([6fd8e7c](6fd8e7c))
* migrate sample event column to text for reporting
([#5503](#5503))
([7d6cbf9](7d6cbf9))
* optimise schema generation function
([#5597](#5597))
([f1818d0](f1818d0))
* recover from badgerdb panic
([#5678](#5678))
([9a47bbd](9a47bbd))
* remove transformations v2 flag
([#5650](#5650))
([3182f9a](3182f9a))
* sync release v1.45.0 to main branch
([#5617](#5617))
([3669407](3669407))
* use rss for calculating used memory in adaptive payload limiter
([#5656](#5656))
([63ff163](63ff163))
* use sonnet as the default json library
([#5657](#5657))
([4c6e5e0](4c6e5e0))
* version deprecation detection avoid regex
([#5625](#5625))
([0d0e7dd](0d0e7dd))
* version deprecation detection logic
([#5644](#5644))
([345162a](345162a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants