-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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 note about how the body is referenced #33935
Conversation
38be28e
to
a1a9f63
Compare
Maybe this deserves some discussion with @elastic/es-clients as there seems to be two ways to achieve the same. But if I remember correctly, $body is used mainly for cat apis, to refer to the last obtained response body as a string, while |
Pinging @elastic/es-core-infra |
I'm labeling this |
ping @elastic/es-clients anybody has opinions on this new note added to the REST spec readme file? |
@javanna, +1 on the note in general but the PR doesn't mention the distinction you've raised. It's not an old style of referring to the body it's semantically different? If so the note should reflect that b |
I've added it only because it caused me some trouble during the development fo the testing suite and it wasn't easy to debug. So, in the end, I see two options:
I'm for the option 1 :) |
Not sure I see the whole picture, but I think the body should be referenced in a transparent, clear way — the empty string is rather confusing, and it's the first time I've actually noticed it. |
Thinking about the example a bit more, I think it's basically a slight abuse of the YAML test DLS... The test in question should probably be written as:
I was surprised that this actually works, and checked I don't have any special logic for handling an empty key. In a sense, this "magically works" in the Ruby runner (as an example), but I think we shouldn't use this notation, and we should prefer a more specific match. |
Agreed, I think that it can be replaced in the example mentioned above, but as far as I see we use this syntax extensively to check the response of exists API, which is expected to be a boolean based on the response code (no response body is returned for HEAD requests). I am not sure that these usages are easily replaceable. I think this is another difference between |
I have looked at an example: elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test/exists/10_basic.yml Line 19 in 2ba18f5
and I think this is another case where it's probably rather confusing for anybody from the outside. In this case, expanding the test language to support something more explicit like the following would make sense?
(Of course, something like |
I think to keep the PR focussed it would be a good first step to first document the current behavior. We can always address the suggestions here in a follow-up. @delvedor can you please go through the discussion here and update your PR accordingly? |
@danielmitterdorfer sure!
|
@delvedor yes I would update the note explaining the distinction that I described above between |
a1a9f63
to
a5b0282
Compare
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 iterating! I left a suggestion.
@@ -316,6 +316,8 @@ Supports also regular expressions with flag X for more readability (accepts whit | |||
\d+ \s+ \d{2}:\d{2}:\d{2} \s+ \d+ \s+ \n $/ | |||
.... | |||
|
|||
**Note:** `$body` is used mainly for cat apis, to refer to the last obtained response body as a string, while `''` refers to the parsed representation of the string (parsed into a Map by the java runner for instance). |
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 think we should start with the description and then provide an example instead of the other way around. How about a slightly different wording?
`$body` is used to refer to the last obtained response body as a string, while `''` refers to the parsed representation (parsed into a Map by the Java runner for instance). Having the raw string response is for example useful when testing cat APIs.
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.
That's fine for me :)
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.
@delvedor can you please change this in your PR? Then I'm happy to approve. :)
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.
Also, please don't use force-pushing as it messes up the history on the PR. Instead, squash the commits when you merge the PR eventually.
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 iterating. LGTM
* elastic/master: (43 commits) Remove remaining occurances of "include_type_name=true" in docs (elastic#37646) SQL: Return Intervals in SQL format for CLI (elastic#37602) Publish to masters first (elastic#37673) Un-assign persistent tasks as nodes exit the cluster (elastic#37656) Fail start of non-data node if node has data (elastic#37347) Use cancel instead of timeout for aborting publications (elastic#37670) Follow stats api should return a 404 when requesting stats for a non existing index (elastic#37220) Remove deprecated FieldNamesFieldMapper.Builder#index (elastic#37305) Document that date math is locale independent Bootstrap a Zen2 cluster once quorum is discovered (elastic#37463) Upgrade to lucene-8.0.0-snapshot-83f9835. (elastic#37668) Mute failing test Fix java time formatters that round up (elastic#37604) Removes awaits fix as the fix is in. (elastic#37676) Mute failing test Ensure that max seq # is equal to the global checkpoint when creating ReadOnlyEngines (elastic#37426) Mute failing discovery disruption tests Add note about how the body is referenced (elastic#33935) Define constants for REST requests endpoints in tests (elastic#37610) Make prepare engine step of recovery source non-blocking (elastic#37573) ...
Hi all!
In some test, such as
get_source/10_basic.yml
the body is referenced as an empty string instead of$body
. This pr adds a note to warn the developers about this behavior.elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/10_basic.yml
Lines 10 to 17 in 3a5b8a7