mozilla-services / cliquet

CLIQUET IS NOW DEPRECATED use kinto.core instead
http://github.com/Kinto/kinto
Other
64 stars 16 forks source link

Batch subrequest doesn't correctly pass the 400 error explaination to the batch response. #617

Closed Natim closed 8 years ago

Natim commented 8 years ago

If you try sending:

{
  "requests": [
    {
      "method": "PUT",
      "headers": {
        "If-None-Match": "'*'"
      },
      "path": "/v1/buckets/default/collections/history/records/zpbhM1shjTMx",
      "body": {
        "data": {
          "id": "zpbhM1shjTMx",
          "payload": "{\"hmac\":\"3cc8fd6a3cf588eeb6921fcf572522406b69d1713be783c6b8c2b9ad69ae8316\",\"ciphertext\":\"tgdRbb4EO2Pkv3XvTIkxiqR6/QSCKMfYfqLfcIV3gcklP16Jd2PAcRIhAeqCJk1HlXLhv9ZbkTRp6B7Db3g/JlfJpvrOG+ooE9sIpSqNJ7hprHu7LBEBphy5KMsaHp1LVE2dx533ssIv39gtvdfLyPMtj+pbanu/cdLWm7Ii15dfk6OU00mGRUvIKDbYbfQs5gUHpZpfqLpNUnbDDAj/2g==\",\"IV\":\"3DjnTHj94GlG6CE8VJBLaA==\"}"
        }
      }
    }
  ]
}

With a wrong If-None-Match header, then the 400 error details will not be send upper

Natim commented 8 years ago

You get:

        {
            "body": {
                "code": 400, 
                "errno": 999, 
                "error": "Bad Request", 
                "message": "Failed batch subrequest"
            }
        }

While you should get:

{
    "code": 400, 
    "details": [
        {
            "description": "Invalid value for If-None-Match", 
            "location": "headers", 
            "name": null
        }
    ], 
    "errno": 107, 
    "error": "Invalid parameters", 
    "message": "headers: Invalid value for If-None-Match"
}
Natim commented 8 years ago

To reproduce call:

BID_AUDIENCE=https://token.services.mozilla.com/ BID_WITH_CLIENT_STATE=True \
    http POST http://localhost:8000/v1/batch @~/batchsyncto.json \
        --auth-type fxa-browserid --auth syncto@trunat.fr

Here is the example JSON file:

{
  "requests": [
    {
      "method": "PUT",
      "headers": {
        "If-None-Match": "'*'"
      },
      "path": "/v1/buckets/default/collections/history/records/zpbhM1shjTMx",
      "body": {
        "data": {
          "id": "zpbhM1shjTMx",
          "payload": "{\"hmac\":\"3cc8fd6a3cf588eeb6921fcf572522406b69d1713be783c6b8c2b9ad69ae8316\",\"ciphertext\":\"tgdRbb4EO2Pkv3XvTIkxiqR6/QSCKMfYfqLfcIV3gcklP16Jd2PAcRIhAeqCJk1HlXLhv9ZbkTRp6B7Db3g/JlfJpvrOG+ooE9sIpSqNJ7hprHu7LBEBphy5KMsaHp1LVE2dx533ssIv39gtvdfLyPMtj+pbanu/cdLWm7Ii15dfk6OU00mGRUvIKDbYbfQs5gUHpZpfqLpNUnbDDAj/2g==\",\"IV\":\"3DjnTHj94GlG6CE8VJBLaA==\"}"
        }
      }
    }
  ]
}