From 255f3e52fb66ae6cb55e24938fff60ec6e28b285 Mon Sep 17 00:00:00 2001 From: kanishkkatara Date: Wed, 4 Sep 2024 16:33:26 +0530 Subject: [PATCH 1/3] fix: add namespace and cluster labels to python transformation functions --- src/util/customTransformer-faas.js | 4 ++++ src/util/openfaas/index.js | 7 +++++++ test/__tests__/user_transformation.test.js | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/util/customTransformer-faas.js b/src/util/customTransformer-faas.js index 07dc205582..0f59f5db60 100644 --- a/src/util/customTransformer-faas.js +++ b/src/util/customTransformer-faas.js @@ -8,6 +8,8 @@ const { executeFaasFunction, FAAS_AST_FN_NAME, FAAS_AST_VID, + PARENT_NAMESPACE, + PARENT_CLUSTER, } = require('./openfaas'); const { getLibraryCodeV1 } = require('./customTransforrmationsStore-v1'); @@ -26,6 +28,8 @@ function generateFunctionName(userTransformation, libraryVersionIds, testMode, h (libraryVersionIds || []).sort(), ); + ids = ids.concat([PARENT_NAMESPACE, PARENT_CLUSTER]); + if (hashSecret !== '') { ids = ids.concat([hashSecret]); } diff --git a/src/util/openfaas/index.js b/src/util/openfaas/index.js index 1f44df86bb..7d4adf2321 100644 --- a/src/util/openfaas/index.js +++ b/src/util/openfaas/index.js @@ -38,6 +38,9 @@ const FAAS_READINESS_HTTP_FAILURE_THRESHOLD = const FAAS_READINESS_HTTP_SUCCESS_THRESHOLD = process.env.FAAS_READINESS_HTTP_SUCCESS_THRESHOLD || '1'; +const PARENT_NAMESPACE = process.env.NAMESPACE || 'default'; +const PARENT_CLUSTER = process.env.FAAS_FN_PARENT_CLUSTER || 'default'; + const CONFIG_BACKEND_URL = process.env.CONFIG_BACKEND_URL || 'https://api.rudderlabs.com'; const GEOLOCATION_URL = process.env.GEOLOCATION_URL || ''; const FAAS_AST_VID = 'ast'; @@ -313,6 +316,8 @@ function buildOpenfaasFn(name, code, versionId, libraryVersionIDs, testMode, trM const labels = { 'openfaas-fn': 'true', 'parent-component': 'openfaas', + 'parent-namespace': PARENT_NAMESPACE, + 'parent-cluster': PARENT_CLUSTER, 'com.openfaas.scale.max': FAAS_MAX_PODS_IN_TEXT, 'com.openfaas.scale.min': FAAS_MIN_PODS_IN_TEXT, 'com.openfaas.scale.zero': FAAS_SCALE_ZERO, @@ -431,6 +436,8 @@ module.exports = { buildOpenfaasFn, FAAS_AST_VID, FAAS_AST_FN_NAME, + PARENT_NAMESPACE, + PARENT_CLUSTER, setFunctionInCache, reconcileFunction, }; diff --git a/test/__tests__/user_transformation.test.js b/test/__tests__/user_transformation.test.js index af3d84173a..eff11b083f 100644 --- a/test/__tests__/user_transformation.test.js +++ b/test/__tests__/user_transformation.test.js @@ -92,6 +92,7 @@ const pyLibCode = (name, versionId) => { const pyfaasFuncName = (workspaceId, versionId, libraryVersionIds=[], hashSecret="") => { let ids = [workspaceId, versionId].concat(libraryVersionIds.sort()); + ids = ids.concat(["default", "default"]); if (hashSecret !== "") { ids = ids.concat([hashSecret]); } @@ -119,7 +120,7 @@ describe("User transformation utils", () => { [], false, 'hash-secret'); - expect(fnName).toEqual('fn-workspaceid-34a32ade07ebbc7bc5ea795b8200de9f'); + expect(fnName).toEqual('fn-workspaceid-91d66b4cea6f0ed16cd41258d138d0a8'); }); }); From 6a81e888729e7b2eb6e93db711a3daeb54f6c42f Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 5 Sep 2024 08:13:06 +0000 Subject: [PATCH 2/3] chore(release): 1.77.1 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc517256bd..fc2f0ba14a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.77.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.77.0...v1.77.1) (2024-09-05) + + +### Bug Fixes + +* add namespace and cluster labels to python transformation functions ([255f3e5](https://github.com/rudderlabs/rudder-transformer/commit/255f3e52fb66ae6cb55e24938fff60ec6e28b285)) + ## [1.77.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.76.1...v1.77.0) (2024-09-02) diff --git a/package-lock.json b/package-lock.json index 489739879b..5b6bde22eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.77.0", + "version": "1.77.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.77.0", + "version": "1.77.1", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "0.7.24", diff --git a/package.json b/package.json index f51501ff91..bb52905347 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.77.0", + "version": "1.77.1", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": { From 632d9af27a5f18de83d699f4464e86f028932e4f Mon Sep 17 00:00:00 2001 From: Jayachand Mopidevi Date: Thu, 12 Sep 2024 19:54:03 +0530 Subject: [PATCH 3/3] chore: adding a new violation type Advance-Rules-Violation (#3715) --- src/util/eventValidation.js | 23 +++++++++++++++++++++++ test/__tests__/eventValidation.test.js | 6 ++++-- test/__tests__/trackingPlan.test.js | 4 ++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/util/eventValidation.js b/src/util/eventValidation.js index 9f3ecd859d..46a494ee5c 100644 --- a/src/util/eventValidation.js +++ b/src/util/eventValidation.js @@ -30,6 +30,7 @@ const violationTypes = { AdditionalProperties: 'Additional-Properties', UnknownViolation: 'Unknown-Violation', UnplannedEvent: 'Unplanned-Event', + AdvanceRulesViolation: 'Advance-Rules-Violation', }; const supportedEventTypes = { @@ -227,6 +228,28 @@ async function validate(event) { }, }; break; + case 'minLength': + case 'maxLength': + case 'pattern': + case 'format': + case 'multipleOf': + case 'minimum': + case 'maximum': + case 'exclusiveMinimum': + case 'exclusiveMaximum': + case 'minItems': + case 'maxItems': + case 'uniqueItems': + case 'enum': + rudderValidationError = { + type: violationTypes.AdvanceRulesViolation, + message: error.message, + meta: { + instancePath: error.instancePath, + schemaPath: error.schemaPath, + }, + }; + break; default: rudderValidationError = { type: violationTypes.UnknownViolation, diff --git a/test/__tests__/eventValidation.test.js b/test/__tests__/eventValidation.test.js index b802b6f886..9f28416457 100644 --- a/test/__tests__/eventValidation.test.js +++ b/test/__tests__/eventValidation.test.js @@ -266,7 +266,8 @@ const validationErrorsTestCases = [ validationErrors: [ { type: "Datatype-Mismatch" }, { type: "Unplanned-Event" }, - { type: "Additional-Properties" } + { type: "Additional-Properties" }, + { type: "Advance-Rules-Violation" } ], output: true }, @@ -283,7 +284,8 @@ const validationErrorsTestCases = [ validationErrors: [ { type: "Datatype-Mismatch" }, { type: "Unplanned-Event" }, - { type: "Additional-Properties" } + { type: "Additional-Properties" }, + { type: "Advance-Rules-Violation" } ], output: true }, diff --git a/test/__tests__/trackingPlan.test.js b/test/__tests__/trackingPlan.test.js index 19606b38b9..1c5db08bd4 100644 --- a/test/__tests__/trackingPlan.test.js +++ b/test/__tests__/trackingPlan.test.js @@ -614,7 +614,7 @@ const eventValidationTestCases = [ trackingPlan, output: [ { - type: "Unknown-Violation", + type: "Advance-Rules-Violation", message: "must be <= 4", meta: { instancePath: "/properties/revenue", @@ -665,7 +665,7 @@ const eventValidationTestCases = [ instancePath: "/properties/dateString", schemaPath: "#/properties/properties/properties/dateString/format", }, - type: "Unknown-Violation", + type: "Advance-Rules-Violation", } ] },