Henrique Santos created UNOMI-933:
-------------------------------------

             Summary: Sending events with bad payloads returns 500
                 Key: UNOMI-933
                 URL: https://issues.apache.org/jira/browse/UNOMI-933
             Project: Apache Unomi
          Issue Type: Bug
          Components: unomi(-core)
    Affects Versions: unomi-3.0.0
            Reporter: Henrique Santos


h2. Summary

Sending events with bad payloads through the `/context.json` endpoint returns 
500 errors. If multiple events are sent and one is badly formatted, none are 
processed.
h2. Steps to Reproduce
 - Deploy Unomi
 - Send data through the API's `/context.json` endpoint using bad payloads. 
Examples:
 -- This request returns 500
{code:bash}
curl --location '/context.json?sessionId=session-1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic a2FyYWY6a2FyYWY=' \
--data 'foo'
{code}
 -- This request returns 500
{code:bash}
curl --location '/context.json?sessionId=session-1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic a2FyYWY6a2FyYWY=' \
--data '{
  "events": [
    {
      "eventType": "view",
      "source": {}
    }
  ]
}'
{code}
 -- This request returns 500
{code:bash}
curl --location '/context.json?sessionId=session-1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic a2FyYWY6a2FyYWY=' \
--data '{
  "events": [
    {
      "eventType": "view",
      "target": {}
    }
  ]
}'
{code}
 -- This request returns 500
{code:bash}
curl --location '/context.json?sessionId=session-1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic a2FyYWY6a2FyYWY=' \
--data '{
  "events": [
    {
      "eventType": "view",
      "target": {
        "itemType": "page"
      }
    }
  ]
}'
{code}
 -- This request returns 500 (note that it contains 2 events, the 1st is 
correct)
{code:bash}
curl --location '/context.json?sessionId=session-1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic a2FyYWY6a2FyYWY=' \
--data '{
  "events": [
    {
      "eventType": "view",
      "target": {
        "itemId": "my-website",
        "itemType": "page"
      }
    },
    {
      "eventType": "view",
      "source": {}
    }
  ]
}'
{code}
 - Call `/cxs/profiles/sessions/session-1`, see that it returns 204 No Content. 
Meaning the correct event wasn't processed.

h2. Actual Result

The bad requests return 500 errors.

h2. Expected Result

The bad requests either get rejected with a 4xx error (with a descriptive 
message of what went wrong), or get processed in a "best effort" and return a 
200 result with the number of processed events.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to