snowplow / enrich

Snowplow Enrichment jobs and library
https://snowplowanalytics.com
Other
21 stars 39 forks source link

Common: iglu Webhook Adapter: Accept array POST requests #42

Open chuwy opened 4 years ago

chuwy commented 4 years ago

Currently sending a JSON-array to the webhook adapter causes the data to fail validation if sent like so:

curl http://acme.com/com.snowplowanalytics.iglu/v1 -H "Content-Type: application/json" -d '[{
    "schema":"iglu:com.acme/event/jsonschema/1-0-0",
    "data": {
      "key":"value"
    }
  }, {
    "schema":"iglu:com.acme/event/jsonschema/1-0-0",
    "data": {
      "key":"value"
    }
  }, {
    "schema":"iglu:com.acme/event/jsonschema/1-0-0",
    "data": {
      "key":"value"
    }
  }]'

Validation error message:

"message": "Iglu event failed: detected SelfDescribingJson but schema key is missing"

Sending a malformed array with no square braces, however, is successful:

curl http://acme.com/com.snowplowanalytics.iglu/v1 -H "Content-Type: application/json" -d '{
    "schema":"iglu:com.acme/event/jsonschema/1-0-0",
    "data": {
      "key":"value"
    }
  }, {
    "schema":"iglu:com.acme/event/jsonschema/1-0-0",
    "data": {
      "key":"value"
    }
  }, {
    "schema":"iglu:com.acme/event/jsonschema/1-0-0",
    "data": {
      "key":"value"
    }
  }'

Iglu webhook adapter should be able to handle a legitimate JSON array of data.

chuwy commented 4 years ago

Migrated from https://github.com/snowplow/snowplow/issues/4127 (comments are auto-generated)