Skip to content

Error with schema validation using dev mode #323

@SimplyComplexable

Description

@SimplyComplexable

I'm getting the following error when I try to use the dev mode version of the tracking plan

Error: strict mode: unknown keyword: "isNewProperty"
    at checkStrictMode (util.js:174:15)
    at checkUnknownRules (util.js:32:13)
    at alwaysValidSchema (util.js:19:5)
    at Object.code (items.js:17:42)
    at keywordCode (index.js:464:13)
    at eval (index.js:222:17)
    at CodeGen.code (index.js:439:13)
    at CodeGen.block (index.js:568:18)
    at iterateKeywords (index.js:219:9)
    at groupKeywords (index.js:200:13)
    at eval (index.js:192:13)
    at CodeGen.code (index.js:439:13)
    at CodeGen.block (index.js:568:18)
    at schemaKeywords (index.js:190:9)
    at typeAndKeywords (index.js:128:5)
    at subSchemaObjCode (index.js:115:5)
    at subschemaCode (index.js:91:13)
    at KeywordCxt.subschema (index.js:438:9)
    at applyPropertySchema (properties.js:45:17)
    at Object.code (properties.js:33:17)
    at keywordCode (index.js:464:13)
    at eval (index.js:222:17)
    at CodeGen.code (index.js:439:13)
    at CodeGen.block (index.js:568:18)
    at iterateKeywords (index.js:219:9)
    at groupKeywords (index.js:200:13)
    at eval (index.js:192:13)
    at CodeGen.code (index.js:439:13)
    at CodeGen.block (index.js:568:18)
    at schemaKeywords (index.js:190:9)
    at typeAndKeywords (index.js:128:5)
    at eval (index.js:70:9)
    at CodeGen.code (index.js:439:13)
    at eval (index.js:37:166)
    at CodeGen.code (index.js:439:13)
    at CodeGen.func (index.js:587:18)
    at validateFunction (index.js:37:13)
    at topSchemaObjCode (index.js:62:5)
    at validateFunctionCode (index.js:21:13)
    at Ajv.compileSchema (index.js:80:45)
    at Ajv._compileSchemaEnv (core.js:473:37)
    at Ajv.compile (core.js:160:38)
    at Ajv.validate (core.js:151:22)
    at validateAgainstSchema (segment.ts:1677:14)
   (... project files)

I can see this isNewProperty field in the schema generated and validated against in the segment.ts file, but obviously I can't change this as it's generated.

{"$id":"Product_Added","$schema":"http://json-schema.org/draft-07/schema#","description":"Fires when a user adds an item to their cart","properties":{"affiliation":{"$id":"/properties/affiliation","description":"","type":"string"},"basket_token":{"$id":"/properties/basket_token","description":"","type":"string"},"brand":{"$id":"/properties/brand","description":"","type":"string"},"cart_id":{"$id":"/properties/cart_id","description":"","type":"string"},"category":{"$id":"/properties/category","description":"","type":"string"},"coupon_name":{"$id":"/properties/coupon_name","description":"","type":["array","null"]},"currency":{"$id":"/properties/currency","description":"","type":"string"},"description":{"$id":"/properties/description","description":"","type":"string"},"essential_products":{"$id":"/properties/essential_products","description":"","type":["array","null"]},"image_url":{"$id":"/properties/image_url","description":"","type":"string"},"list_name":{"$id":"/properties/list_name","description":"","type":"string"},"name":{"$id":"/properties/name","description":"","type":"string"},"price":{"$id":"/properties/price","description":"","type":"number"},"product_id":{"$id":"/properties/product_id","description":"","type":"string"},"products":{"$id":"/properties/products","description":"","items":{"$id":"/properties/properties/properties/products/items","description":"","isNewProperty":true,"properties":{"category":{"$id":"/properties/properties/properties/products/items/properties/category","description":"","type":"string"},"description":{"$id":"/properties/properties/properties/products/items/properties/description","description":"","type":"string"},"discount":{"$id":"/properties/properties/properties/products/items/properties/discount","description":"","type":"number"},"image_url":{"$id":"/properties/properties/properties/products/items/properties/image_url","description":"","type":"string"},"name":{"$id":"/properties/properties/properties/products/items/properties/name","description":"","type":"string"},"position":{"$id":"/properties/properties/properties/products/items/properties/position","description":"","type":"number"},"price":{"$id":"/properties/properties/properties/products/items/properties/price","description":"","type":"number"},"product_id":{"$id":"/properties/properties/properties/products/items/properties/product_id","description":"","type":"string"},"quantity":{"$id":"/properties/properties/properties/products/items/properties/quantity","description":"","type":"number"},"sku":{"$id":"/properties/properties/properties/products/items/properties/sku","description":"","type":"string"},"url":{"$id":"/properties/properties/properties/products/items/properties/url","description":"","type":"string"},"variant":{"$id":"/properties/properties/properties/products/items/properties/variant","description":"","type":"string"}},"required":[],"type":"object"},"type":"array"},"quantity":{"$id":"/properties/quantity","description":"","type":"number"},"sku":{"$id":"/properties/sku","description":"","type":"string"},"url":{"$id":"/properties/url","description":"","type":"string"},"variant":{"$id":"/properties/variant","description":"","type":"string"}},"required":["brand","affiliation"],"type":"object"}

It seems similar to this issue resolved with this PR. So I think these properties just need to be stripped before writing the file, but not certain.

Thanks for looking into this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions