Skip to content

Fix optional/missing fields reported via Java client issues #1823

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

Merged
merged 1 commit into from
Aug 25, 2022

Conversation

swallez
Copy link
Member

@swallez swallez commented Aug 23, 2022

This PR fixes a number of fields that should be optional and also adds SearchRequest.ext that is undocumented but is present in HLRC and used by some plugins to add new sections to search requests.

These are bug fixes that should be backported down to 7.17.

@swallez swallez requested a review from sethmlarson August 23, 2022 17:05
@swallez swallez added the lang:java Affects/found in the Java client label Aug 23, 2022
@github-actions
Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
async_search.submit 🟢 7/7 7/7
cluster.allocation_explain 🟢 4/4 4/4
cluster.delete_component_template 🟢 2/2 2/2
cluster.delete_voting_config_exclusions 🟢 1/1 1/1
cluster.exists_component_template Missing test Missing test
cluster.get_component_template 🟢 8/8 8/8
cluster.get_settings 🟢 7/7 7/7
cluster.health 🟢 139/139 139/139
cluster.pending_tasks 🟢 3/3 3/3
cluster.post_voting_config_exclusions 🔴 5/5 1/5
cluster.put_component_template 🔴 12/14 14/14
cluster.put_settings 🟢 42/42 41/41
cluster.remote_info 🟢 3/3 3/3
cluster.reroute 🟢 6/6 5/5
cluster.state 🟢 74/74 73/73
cluster.stats 🔴 10/10 0/10
fleet.search Missing test Missing test
indices.add_block 🟢 2/2 2/2
indices.analyze 🟢 20/20 20/20
indices.clear_cache 🟢 4/4 4/4
indices.clone 🟢 6/6 6/6
indices.close 🟢 43/43 43/43
indices.create_data_stream 🟢 25/25 25/25
indices.create 🔴 688/710 710/710
indices.data_streams_stats 🟢 4/4 4/4
indices.delete_alias 🟢 15/15 15/15
indices.delete_data_stream 🟢 27/27 27/27
indices.delete_index_template 🟢 1/1 1/1
indices.delete_template 🟢 9/9 9/9
indices.delete 🟢 104/104 104/104
indices.disk_usage 🟢 4/4 4/4
indices.exists_alias 🟢 36/36 36/36
indices.exists_index_template Missing test Missing test
indices.exists_template 🟢 15/15 15/15
indices.exists 🟢 39/39 39/39
indices.field_usage_stats 🟢 5/5 5/5
indices.flush 🟢 9/9 9/9
indices.forcemerge 🔴 4/4 3/4
indices.get_alias 🔴 82/82 70/82
indices.get_data_stream 🟢 12/12 12/12
indices.get_field_mapping 🔴 15/15 14/15
indices.get_index_template 🔴 16/16 14/16
indices.get_mapping 🔴 60/60 59/60
indices.get_settings 🔴 54/54 47/54
indices.get_template 🟢 30/30 30/30
indices.get 🔴 52/52 48/52
indices.migrate_to_data_stream Missing test Missing test
indices.modify_data_stream Missing test Missing test
indices.open 🟢 17/17 17/17
indices.promote_data_stream Missing test Missing test
indices.put_alias 🟢 55/55 55/55
indices.put_index_template 🔴 37/38 38/38
indices.put_mapping 🔴 70/74 74/74
indices.put_settings 🔴 46/49 49/49
indices.put_template 🔴 40/46 46/46
indices.recovery 🟢 11/11 11/11
indices.refresh 🟢 199/199 199/199
indices.reload_search_analyzers 🟢 2/2 2/2
indices.resolve_index 🟢 6/6 6/6
indices.rollover 🔴 15/26 26/26
indices.segments 🔴 6/6 4/6
indices.shard_stores 🔴 5/5 2/5
indices.shrink 🟢 5/5 5/5
indices.simulate_index_template 🟢 6/6 6/6
indices.simulate_template 🟢 4/4 4/4
indices.split 🟢 5/5 5/5
indices.stats 🟢 83/83 82/82
indices.unfreeze 🟢 1/1 1/1
indices.update_aliases 🟢 22/22 22/22
indices.validate_query 🟢 7/7 7/7
msearch 🟢 17/17 16/16
search 🔴 1483/1540 1508/1522
security.get_token 🟢 23/23 22/22

You can validate these APIs yourself by using the make validate target.

@@ -36,7 +36,7 @@ export class ErrorCause
/**
* A human-readable explanation of the error, in english
*/
reason: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm! When can an error not have a reason?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went digging to understand this, as it was surprising but happening in the wild ;-)

ErrorCause is the JSON representation of a Java exception (a Throwable). The reason field is the result of Java's Throwable.getMessage(), which according to the docs can be null. In practice this never (I guess) happens for the top-level error, which is generally an ElasticsearchException. The error here happened in a deeper root cause, where apparently getMessage() returned null 🤷

Copy link

@Enerccio Enerccio Aug 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null can happen when it's same exception as before in case of NullPointerException - jvm can optimize them out

@@ -21,7 +21,7 @@ import { Dictionary } from '@spec_utils/Dictionary'
import { Field } from '@_types/common'
import { Script } from '@_types/Scripting'

export type RuntimeFields = Dictionary<Field, RuntimeField | RuntimeField[]>
export type RuntimeFields = Dictionary<Field, RuntimeField>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why this originally was made an array?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea. There's no occurrence of the array variant in our recordings and looking at the ES source code it has always expected the mapping to be an object and not an array.

Copy link
Contributor

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few questions, the rest of the changes look good.

Copy link
Contributor

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@swallez swallez merged commit 33dd057 into main Aug 25, 2022
@swallez swallez deleted the misc-java-fixes-220822 branch August 25, 2022 10:45
@github-actions
Copy link
Contributor

The backport to 7.17 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-7.17 7.17
# Navigate to the new working tree
cd .worktrees/backport-7.17
# Create a new branch
git switch --create backport-1823-to-7.17
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 33dd0578abec42e588e7cbcf35ad9d9d29723190
# Push it to GitHub
git push --set-upstream origin backport-1823-to-7.17
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-7.17

Then, create a pull request where the base branch is 7.17 and the compare/head branch is backport-1823-to-7.17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants