Skip to content

Support maxProperties=1 constraints by marking them as oneof for protobuf generation - #317

Merged
lucy66hw merged 2 commits into
opensearch-project:mainfrom
lucy66hw:min/maxProperties1
Dec 3, 2025
Merged

Support maxProperties=1 constraints by marking them as oneof for protobuf generation#317
lucy66hw merged 2 commits into
opensearch-project:mainfrom
lucy66hw:min/maxProperties1

Conversation

@lucy66hw

@lucy66hw lucy66hw commented Dec 1, 2025

Copy link
Copy Markdown
Collaborator

Description

Support maxProperties=1 constraints by marking them as oneof for protobuf generation

Test

lucy66hw#63
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…ts by marking them as `oneof` for protobuf generation

Signed-off-by: xil <fridalu66@gmail.com>
@lucy66hw lucy66hw changed the title Min/max properties1 Support minProperties=1 and maxProperties=1 constraints by marking them as oneof for protobuf generation Dec 1, 2025
@lucy66hw
lucy66hw marked this pull request as ready for review December 1, 2025 04:42
@karenyrx

karenyrx commented Dec 1, 2025

Copy link
Copy Markdown
Collaborator

Pasting convo from slack for reference:

This is my understanding of the expected behavior of min/max=1 (let me know if i got this right)

  1. case 1: if min/max properties=1 exists, and has properties but no additionalProperties (e.g. for SpanQuery)
    -> then we wrap the properties inside a proto oneof
  2. case 2: if min/max properties=1 , and has additionalProperties , but no properties (e.g. fuzzy) ,
    -> then we convert to string field instead of map<> with 1 element
  3. case 3: if min/maxproperties=1 and has both additionalProperties and properties (e.g. TermsQuery)
    -> then the min/max=1 applies for the properties field not the additionalProperties
    just wondering which case (1, 2, or 3) this PR implements, or all 3

This PR is to implement case 1. the case 2 had already implemented previously. it already changed the schema to not having additionalProperty. for case3, it would be the corner case that we can't handle it properly.

Summary:

  • Case 2 has a separate rule to take care of it, before case 1/3 rules are appied.
  • This PR implements case 1
  • Throw error for case 3

Signed-off-by: xil <fridalu66@gmail.com>
@lucy66hw lucy66hw changed the title Support minProperties=1 and maxProperties=1 constraints by marking them as oneof for protobuf generation Support maxProperties=1 constraints by marking them as oneof for protobuf generation Dec 2, 2025
@karenyrx

karenyrx commented Dec 2, 2025

Copy link
Copy Markdown
Collaborator

Removing minProperties=1 in proto makes sense since there is no way to represent this in protos, and should be validated in server-side code instead.

@lucy66hw
lucy66hw merged commit 07dcf00 into opensearch-project:main Dec 3, 2025
9 checks passed
@lucy66hw
lucy66hw deleted the min/maxProperties1 branch December 10, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants