-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add body validation to update follower index API endpoint. #63653
Add body validation to update follower index API endpoint. #63653
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the stringify
is not needed anymore as the httpClient takes care of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did a test and confirmed we still need to stringify the body.
@@ -164,6 +164,18 @@ export const registerFollowerIndexRoutes = ({ router, __LEGACY }: RouteDependenc | |||
path: `${API_BASE_PATH}/follower_indices/{id}`, | |||
validate: { | |||
params: schema.object({ id: schema.string() }), | |||
body: schema.object({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done this in #62890, so I'm going to leave it out of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 Out
Stack Trace
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.