Skip to content

Typewriter JSON Schema Validation Error for Date objects #313

@ivark16

Description

@ivark16

About

Hello, I'm using typewriter and just encountered this problem where I get a validation error stating that JSON Schema doesn't match the Tracking plan spec in the console.

Environment

$ node --version
v16.10.0
$ yarn --version
1.22.19
$ tsc --version 
Version 4.9.5

Using current version of typewriter: 9.1.0

The problem

In my tracking plan I have a property called destination_date_time which is of type Date time.

Automatically generated typewriter client file has this property listed as destination_date_time?: Date;

The plan.json file has this specific property listed as:

"destination_date_time": {
  "$id": "...",
  "description": "...",
  "format": "date-time",
  "type": "string"
},

And when making this call to Segment I get this warning in my console:

 "type": "Typewriter JSON Schema Validation Error",
  "description": "You made an analytics call (undefined) using Typewriter that doesn't match the Tracking Plan spec.",
  "errors": [
    {
      "keyword": "type",
      "dataPath": ".products[0].destination_date_time",
      "schemaPath": "#/properties/products/items/properties/destination_date_time/type",
      "params": {
        "type": "string"
      },
      "message": "should be string",
      "schema": "string",
      "parentSchema": {
        "$id": "...",
        "description": "....",
        "format": "date-time",
        "type": "string"
      },
      "data": "2023-11-09T10:45:00.000Z"
    },
    .
    . 
    . 

I have tried just giving it new Date() as value to check if it was my data that wasn't of the right type but I still get the same error. And if I try feeding it any other than Date typewriter will give me an error saying it only accepts Date types but then again I get this issue in the console when developing locally. Not sure if this is a known issue or not but wanted to raise this and ask if there is any way around getting this warning 😄

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