Fix PathHierarchyTokenizer optional fields incorrectly marked required causing deserialization failure - #2038
Open
gingeekrishna wants to merge 9 commits into
Conversation
gingeekrishna
requested review from
Bukhtawar,
VachaShah,
Xtansia,
madhusudhankonda,
saratvemulapalli and
szczepanczykd
as code owners
July 5, 2026 07:43
gingeekrishna
pushed a commit
to gingeekrishna/opensearch-java
that referenced
this pull request
Jul 5, 2026
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishnan@gmail.com>
gingeekrishna
pushed a commit
to gingeekrishna/opensearch-java
that referenced
this pull request
Aug 16, 2026
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishnan@gmail.com>
gingeekrishna
force-pushed
the
fix/1797-path-hierarchy-tokenizer-optional-fields
branch
from
August 16, 2026 16:12
2fed78c to
2dd5949
Compare
reta
requested changes
Aug 16, 2026
Collaborator
There was a problem hiding this comment.
Please submit a change against https://github.com/opensearch-project/openSearch-api-specification, thank you
Author
There was a problem hiding this comment.
Submitted the spec fix upstream: opensearch-project/opensearch-api-specification#1195
Author
|
Submitted the spec fix upstream: opensearch-project/opensearch-api-specification#1195 |
gingeekrishna
pushed a commit
to gingeekrishna/opensearch-java
that referenced
this pull request
Aug 30, 2026
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishnan@gmail.com>
gingeekrishna
force-pushed
the
fix/1797-path-hierarchy-tokenizer-optional-fields
branch
from
August 30, 2026 06:27
2dd5949 to
0d49134
Compare
gingeekrishna
pushed a commit
to gingeekrishna/opensearch-java
that referenced
this pull request
Aug 30, 2026
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishnan@gmail.com>
gingeekrishna
force-pushed
the
fix/1797-path-hierarchy-tokenizer-optional-fields
branch
from
August 30, 2026 06:35
0d49134 to
293baef
Compare
…rsing_exception The _common___DerivedField schema in opensearch-openapi.yaml included a required name property. This caused DerivedField.java to serialize a name key into the JSON mapping body, but the OpenSearch API does not accept name inside a derived field definition and returns: mapper_parsing_exception: unknown parameter [name] on mapper In the API, the derived field's name is expressed as the map key in the parent derived object, not as a property inside the field definition. Remove name from the _common___DerivedField schema (both from properties and required) and update the generated DerivedField.java accordingly. The Java client no longer serializes name inside derived field definitions. Fixes opensearch-project#1937 Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
…ailure ShardFailure.shard was marked as required in the spec, so the generated class threw MissingRequiredPropertyException when OpenSearch returned a ShardFailure without the shard field — masking the real failure. Per the OpenSearch API, shard is an optional integer in ShardFailure (the primary failure reason is always present; the shard number may be absent for certain failure types). Remove shard from the required list in _common___ShardFailure and update the generated ShardFailure.java to use @nullable Integer with proper null guards in serialization, hashCode, and equals. Fixes opensearch-project#1799 Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
The previous commit made shard optional, on the assumption the server sometimes omits it. Per review on the corresponding spec change (opensearch-project/opensearch-api-specification#1194), that was wrong: ReplicationResponse.ShardInfo.Failure on the server always writes the field. The real bug was a JSON key mismatch: the server writes _index, _shard, _node (underscore-prefixed), but the spec and this client used index, shard, node, so deserialization looked up the wrong key and threw MissingRequiredPropertyException on _shard/shard, or silently dropped _index/_node. Revert shard to a required, non-null int, and rename the three JSON keys (index/node/shard -> _index/_node/_shard) in both opensearch-openapi.yaml and the generated ShardFailure.java. Java accessor/builder names are unchanged (index(), node(), shard()) per the existing convention for underscore-prefixed API fields (see Hit.index() for _index). Signed-off-by: Radhakrishnan P <gingeekrishna@gmail.com>
Signed-off-by: Radhakrishnan P <gingeekrishna@gmail.com>
…ilure buffer_size, delimiter, reverse, and skip were marked required in the spec, so any index using a PathHierarchyTokenizer configured with OpenSearch defaults (omitting these optional parameters) could not be retrieved — the client threw: Missing required property 'PathHierarchyTokenizer.bufferSize' All four parameters are optional in the OpenSearch API with documented defaults (buffer_size=1024, delimiter=/, reverse=false, skip=0). Only type is actually required. Remove buffer_size, delimiter, reverse, skip from required in the spec and update the generated class to use @nullable types with proper null guards in serialization, hashCode, and equals. Fixes opensearch-project#1797 Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishnan@gmail.com>
gingeekrishna
force-pushed
the
fix/1797-path-hierarchy-tokenizer-optional-fields
branch
from
September 4, 2026 05:55
293baef to
edabcb6
Compare
Left over from making buffer_size/delimiter/reverse/skip optional - none of them use ApiTypeHelper.requireNonNull anymore, so the import became dead. Caught by CI's spotlessJavaCheck and the "Ensure Generated Code Is Up To Date" job (the real code generator doesn't emit unused imports). Signed-off-by: Radhakrishnan P <gingeekrishna@gmail.com>
The previous commits made buffer_size/delimiter/reverse/skip nullable fields but left their Builder setters taking primitive int/boolean (or non-@nullable String) parameters - the required-field shape. CI's "Ensure Generated Code Is Up To Date" job still reported the file as dirty after the unused-import fix, since the real generator wouldn't produce that mismatch. Match the convention used elsewhere for optional fields (e.g. EdgeNGramTokenFilter.maxGram/minGram): boxed, @nullable setter parameters, and @nullable on the corresponding Builder field. Signed-off-by: Radhakrishnan P <gingeekrishna@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #1797
Problem: Any index using
PathHierarchyTokenizerconfigured with OpenSearch defaults (omitting optional parameters) cannot be retrieved via the Java client:Root cause:
_common.analysis___PathHierarchyTokenizerinopensearch-openapi.yamllistedbuffer_size,delimiter,reverse, andskipinrequired. However these are all optional parameters with documented OpenSearch defaults:buffer_size— default 1024delimiter— default/reverse— defaultfalseskip— default 0When an index is created without explicitly setting these, OpenSearch omits them from the response and the client throws
MissingRequiredPropertyException.Fix: Remove
buffer_size,delimiter,reverse,skipfromrequired(onlytyperemains required) and update the generatedPathHierarchyTokenizer.javato use@Nullabletypes with null guards in serialization,hashCode, andequals.Changes
java-codegen/opensearch-openapi.yaml— remove 4 fields fromrequiredjava-client/src/generated/java/org/opensearch/client/opensearch/_types/analysis/PathHierarchyTokenizer.java— make all 4 fields nullable throughout