Error with array datatype

HI!

We already using SP. And we are using custom (unstructured) events.
And we have already used arrays in event parameters.
Everything was fine and after 15 of June we have this kind of error.
Shema does exist.

“errors”:[{“level”:“error”,“message”:"error: Could not find schema with key iglu:ru.napolke.sp/banner_click/jsonschema/1-0-0 in any repository, tried:\n

level: “error”\n repositories: [“Local cached IGLU repository mirror [HTTP]”,“Iglu Client Embedded [embedded]”,“Custom schemas IGLU repository [HTTP]”]\n"},{“level”:“error”,“message”:"error: “array(string)” is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])\n

level: “error”\n domain: “syntax”\n schema: {“loadingURI”:"#",“pointer”:"/properties/brand_id"}\n keyword: “type”\n found: “array(string)”\n valid: [“array”,“boolean”,“integer”,“null”,“number”,“object”,“string”]\n"},{“level”:“error”,“message”:"error: “array(string)” is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])\n

We are using Crate DB.

Sсhema:

{
“$schema”: “https://sp.napolke.ru/schemas/ru.napolke.sp/banner_click/jsonschema/1-0-0”,
“description”: “Napolke snowplow autogenerated schema”,
“self”: {
“vendor”: “ru.napolke.sp”,
“name”: “banner_click”,
“format”: “jsonschema”,
“version”: “1-0-0”
},
“type”: “object”,
“properties”: {
“banner_name”: {
“type”: “array(string)”
},
“banner_size”: {
“type”: “array(string)”
},
“banner_tracker”: {
“type”: “array(string)”
},
“banner_shape”: {
“type”: “array(string)”
},
“supplier_id”: {
“type”: “array(string)”
},
“category_id”: {
“type”: “array(string)”
},
“brand_id”: {
“type”: “array(string)”
},
“catalog_id”: {
“type”: “array(string)”
}
},
“additionalProperties”: false
}

Hi @rodion_zhukov,

I can see a couple of things to fix - first up, you need to use JSONSchema to define your types - here are the JSONSchema docs on arrays. For an array of strings it should be:

{
  "type": "array",
  "items": {
    "type": "string"
  }
}

Second, the $schema field in your schema shouldn’t refer to the path of the schema itself (although it seems this way intuitively). Instead it should refer to the path to the metaschema for Self-describing JSON:

"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#"

Hope that helps!

4 Likes

Hi we have implemented new schema:
https://sp.napolke.ru/schemas/ru.napolke.sp/popup_view/jsonschema/1-0-0

{
  "$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
  "description": "Napolke snowplow autogenerated schema",
  "self": {
    "vendor": "ru.napolke.sp",
    "name": "popup_view2",
    "format": "jsonschema",
    "version": "1-0-0"
  },
  "type": "object",
  "properties": {
    "type": {
      "type": "string"
    },
    "catalog_type": {
      "type": "string"
    }
  },
  "additionalProperties": false
}

JS event:
    sp_nap('trackSelfDescribingEvent', {
    	schema: 'iglu:ru.napolke.sp/popup_view2/jsonschema/1-0-0',
        data: {type: 'test', catalog_type: 'test2'}})

And now i get this type of error:
"errors":[{"level":"error","message":"error: Could not find schema with key iglu:ru.napolke.sp/popup_view2/jsonschema/1-0-0 in any repository, tried:\n level: \"error\"\n repositories: [\"Local cached IGLU repository mirror [HTTP]\",\"Iglu Client Embedded [embedded]\",\"Custom schemas IGLU repository [HTTP]\"]\n"}],"failure_tstamp":"2020-08-14T19:50:30.585Z"}

I reload SP several times but can’t find the reason.
Can you help please?

@rodion_zhukov, what do you mean by “reload SP”? Depending on your pipeline architecture you might need to restart the enrichment component to clear cache. Also, I’m sceptical about the property you named “type” as type is the keyword in JSON schemas and it might cause issues perhaps.