-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Assert that REST params are consumed iff supported #113933
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
Assert that REST params are consumed iff supported #113933
Conversation
f9844df
to
2902035
Compare
REST APIs which declare their supported parameters must consume exactly those parameters: consuming an unsupported parameter means that requests including that parameter will be rejected, whereas failing to consume a supported parameter means that this parameter has no effect and should be removed. This commit adds an assertion to verify that we are consuming the correct parameters. Closes elastic#113854
6c6e45e
to
e33234e
Compare
Pinging @elastic/es-core-infra (Team:Core/Infra) |
private boolean assertConsumesSupportedParams(@Nullable Set<String> supported, RestRequest request) { | ||
if (supported != null) { | ||
final var supportedAndCommon = new TreeSet<>(supported); | ||
supportedAndCommon.addAll(List.of("error_trace", "filter_path", "format", "pretty", "human")); |
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.
Do we have these common params defined anywhere so this isn't an arbitrary list?
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.
Eh not all of them. There's org.elasticsearch.rest.BaseRestHandler#ALWAYS_SUPPORTED
but that doesn't include error_trace
. I pushed a commit that uses ALWAYS_SUPPORTED
. Not a huge deal here in any case, if we get this wrong then this assertion will trip.
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
💔 Backport failed
You can use sqren/backport to manually backport by running |
REST APIs which declare their supported parameters must consume exactly those parameters: consuming an unsupported parameter means that requests including that parameter will be rejected, whereas failing to consume a supported parameter means that this parameter has no effect and should be removed. This commit adds an assertion to verify that we are consuming the correct parameters. Closes elastic#113854 Backport of elastic#113933 to `8.x`
REST APIs which declare their supported parameters must consume exactly those parameters: consuming an unsupported parameter means that requests including that parameter will be rejected, whereas failing to consume a supported parameter means that this parameter has no effect and should be removed. This commit adds an assertion to verify that we are consuming the correct parameters. Closes elastic#113854
Bah this had a bug, I reverted it and will open a fresh PR. |
REST APIs which declare their supported parameters must consume exactly those parameters: consuming an unsupported parameter means that requests including that parameter will be rejected, whereas failing to consume a supported parameter means that this parameter has no effect and should be removed. This commit adds an assertion to verify that we are consuming the correct parameters. Closes elastic#113854
REST APIs which declare their supported parameters must consume exactly
those parameters: consuming an unsupported parameter means that requests
including that parameter will be rejected, whereas failing to consume a
supported parameter means that this parameter has no effect and should
be removed.
This commit adds an assertion to verify that we are consuming the
correct parameters.
Closes #113854