EUDAT-B2STAGE / http-api

RESTful HTTP-API for the B2STAGE service inside the EUDAT project
https://eudat-b2stage.github.io/http-api/
MIT License
7 stars 7 forks source link

Seadata: Response code 200 and still an error (seadata: uploading a file twice / duplicate container) #122

Closed merretbuurman closed 6 years ago

merretbuurman commented 6 years ago

When a container is created which already exists (Seadata - Ingestion), there is a Rancher error that says NotUnique, and this is transformed to a response with code=200 but an error inside is. This is confusing. Either, it is an error, then don't return 200. Or it is not an error, then we should include this as a message, not as an error.

backend_1 | 2018-08-29T14:11:16.791610968Z { backend_1 | 2018-08-29T14:11:16.791632094Z 'Meta': { backend_1 | 2018-08-29T14:11:16.791649268Z 'data_type': '<class 'dict'>', backend_1 | 2018-08-29T14:11:16.791666878Z 'elements': 3, backend_1 | 2018-08-29T14:11:16.791683225Z 'errors': 0, backend_1 | 2018-08-29T14:11:16.791699708Z 'status': 200, backend_1 | 2018-08-29T14:11:16.791729326Z }, backend_1 | 2018-08-29T14:11:16.791746512Z 'Response': { backend_1 | 2018-08-29T14:11:16.791762935Z 'data': { backend_1 | 2018-08-29T14:11:16.791779392Z 'batch_id': 'log42', backend_1 | 2018-08-29T14:11:16.791795679Z 'errors': { backend_1 | 2018-08-29T14:11:16.791812539Z 'error': {'status': 422, 'code': 'NotUnique', 'message': None, 'detail': None, 'fieldName': 'name', 'baseType': 'error'} backend_1 | 2018-08-29T14:11:16.791830052Z }, backend_1 | 2018-08-29T14:11:16.791846462Z 'status': 'existing', backend_1 | 2018-08-29T14:11:16.791862949Z }, backend_1 | 2018-08-29T14:11:16.791879419Z 'errors': None, backend_1 | 2018-08-29T14:11:16.791895842Z }, backend_1 | 2018-08-29T14:11:16.791911786Z }

merretbuurman commented 6 years ago

You can assign this to me if you want ;)

merretbuurman commented 6 years ago

Btw, the response is not returned to the client because of issue #123 , so both would have to be fixed at the same time.

mdantonio commented 6 years ago

Should be switched to a proper http error status, like 409 Conflict or 400 Bad Request

mdantonio commented 6 years ago

Assigned 409 Conflict status for NonUnique errors. 400 bad request for other rancher errors