Add body validation to update follower index API endpoint.#63653
Add body validation to update follower index API endpoint.#63653cjcenizal merged 3 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
sebelga
left a comment
There was a problem hiding this comment.
LGTM! Tested locally and the bug is fixed. I created a PR to add the tests (API integration + component integration) to avoid possible regression in the future.
Once tests are added I'll approve 👍
|
|
||
| const request = httpClient.put(`${API_BASE_PATH}/follower_indices/${encodeURIComponent(id)}`, { | ||
| body: JSON.stringify(followerIndex), | ||
| body: JSON.stringify({ |
There was a problem hiding this comment.
Nit: the stringify is not needed anymore as the httpClient takes care of it.
There was a problem hiding this comment.
Hm, do you know whether this is also the case for public side httpClient? I seem to recall the JSON.stringify being required there.
There was a problem hiding this comment.
I just did a test and confirmed we still need to stringify the body.
| path: `${API_BASE_PATH}/follower_indices/{id}`, | ||
| validate: { | ||
| params: schema.object({ id: schema.string() }), | ||
| body: schema.object({ |
There was a problem hiding this comment.
It would be better to declare the schema outside the route handler so we can re-use and compose it for the create route.
There was a problem hiding this comment.
I've done this in #62890, so I'm going to leave it out of this PR.
There was a problem hiding this comment.
Thanks for finding and fixing this @cjcenizal ! It's kind of extra tricksy because at runtime the body, without validation is {} which is really unfortunate because we would definitely have caught this bug otherwise. Hopefully we can make 7.7.0!
|
|
||
| const request = httpClient.put(`${API_BASE_PATH}/follower_indices/${encodeURIComponent(id)}`, { | ||
| body: JSON.stringify(followerIndex), | ||
| body: JSON.stringify({ |
There was a problem hiding this comment.
Hm, do you know whether this is also the case for public side httpClient? I seem to recall the JSON.stringify being required there.
|
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Test FailuresKibana Pipeline / kibana-oss-agent / Accessibility Tests.test/accessibility/apps/discover·ts.Discover should open context view on a docStandard OutStack TraceHistory
To update your PR or re-run it, just comment with: |
sebelga
left a comment
There was a problem hiding this comment.
I'll approve to not block it but you are also missing the component integration tests that I added in the PR.
I'd like this PR cjcenizal#24 to not get stale and have people's feedback on it. cc @jloleysens @alisonelizabeth @cjcenizal @cuff-links
…c#63653. - Fix route validation errors and API request.
Thanks for pointing this out. I'll add it in another PR. |
Fixes #62943
When we migrated the server to NP we left out some route validation (https://github.com/elastic/kibana/pull/60121/files#diff-8ae5a51616bdcb1706f0aaf1ab1581c9R173). This means the body gets stripped from requests. I tested the other endpoints and I believe this is the only endpoint to have this type of regression. I'm improving the validation of other routes to be more strict in #62890.
Note that I will update the release label to be 7.7.1 and add a release note if we don't make 7.7.0.