-
Notifications
You must be signed in to change notification settings - Fork 641
Description
On preforming a duplicate insert the datastore normally returns
{ "error": { "errors": [ { "domain": "global", "reason": "INVALID_ARGUMENT", "message": "entity already exists" } ], "code": 400, "message": "entity already exists" } }
but instead 'errors' in the ApiError are an []
Is this intentional?
From some digging around, the problem is in lib/datastore/request.js
line 813 creates the request
813: ... request(authenticatedReqOpts, function(err, resp, body)
The value of body is already the expected json error message.
On 'line 819' util.parseHttpRespMessage(resp) sets parsedResp with ApiError with [] for errors.
The callback is called and body param with the nicely formatted error is lost.
The 'message' field is filled but it has the stringified error which would require re-parsing
Bad Request - { "error": { "errors": [ { "domain": "global", "reason": "INVALID_ARGUMENT", "message": "entity already exists" } ], "code": 400, "message": "entity already exists" } }