Conversation
| console.log(realUrl); | ||
| console.log(''); | ||
| console.log('request body'); | ||
| console.log(req.body); |
There was a problem hiding this comment.
I'd like to leave this logging in the server logs, to aid debugging similar issues in the future. I'm happy to modify the formatting if reviewers recommend this.
There was a problem hiding this comment.
Not against this but one option here is to gate this behind a local storage toggle for debugging. It would prevent unnecessarily logging at all times.
14befce to
65289f6
Compare
| console.log(realUrl); | ||
| console.log(''); | ||
| console.log('request body'); | ||
| console.log(req.body); |
There was a problem hiding this comment.
Not against this but one option here is to gate this behind a local storage toggle for debugging. It would prevent unnecessarily logging at all times.
| request[method](options, (error, response, body) => { | ||
| if (error) { | ||
| res.status(500).send(error); | ||
| res.status(response.statusCode || 500).send(error); |
There was a problem hiding this comment.
Is there ever a case where the statusCode will be empty?
There was a problem hiding this comment.
Good call, will handle this.
|
This PR is ready to be merged, approved by @somecodemonkey Ensure request body is sent from helix-front to helix-rest (#2221 )Fix Angular http payload argument bug |
Description
This PR fixes a bug that occurs because the request body is now ignored silently by the Angular http library if it is passed as stringified JSON. Now, all request bodies are passed as objects, which the Angular http library then stringifies itself.
This PR also passes the http response status code from the helix-front web server to the UI, so that response codes from the helix-rest like
400 Bad Requestare shown in the UI. This helps the user better understand what is going wrong.This PR also ensures that the response sent from helix-front to helix-rest is identical to the working curl request.
Here is the desired payload format, modeled after the working curl request:
{ "id": "my-test-cluster", "mapFields": { "TEST_FIELD": { "test_sub_field": 18 } } }Here is the bug format seen before, which differed slightly from the curl request:
{ "id": "my-test-cluster", "mapFields": { "TEST_FIELD": { "test_sub_field": "18" } }, "listFields": {}, "simpleFields": {} }Notice the following differences:
"test_sub_field"is a string, not a number.Fix #2221
Tests
TODO: add a test for this case.
Code Style
Formatted using Prettier