Skip to content

[BUG] required spec not respected for maps and lists #1813

@moesterheld

Description

@moesterheld

What is the bug?

In the spec, a null value can be allowed for lists, e.g. here:
https://github.com/opensearch-project/opensearch-api-specification/blob/963f90293d480015deaf352d1987bec2f18916c2/spec/schemas/ism._common.yaml#L50-L57

Deserializing these will fail with a NPE due to the Objects.requireNonNull in _listAddAll

How can one reproduce the bug?

ISM Policies can be created without nested ISM Templates. As an example, see the create policy request/response in the docs

However, reading a policy created like this without the client fails due to the list being null

java.lang.NullPointerException
	at java.base/java.util.Objects.requireNonNull(Objects.java:233)
	at org.opensearch.client.util.ObjectBuilderBase._listAddAll(ObjectBuilderBase.java:101)
	at org.opensearch.client.opensearch.ism.Policy$Builder.ismTemplate(Policy.java:379)
	at org.opensearch.client.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:82)
	at org.opensearch.client.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:185)
	at org.opensearch.client.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:146)
	at org.opensearch.client.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:87)
	at org.opensearch.client.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:91)

What is the expected behavior?

lists and maps should respect required like all other properties. If this is not possible, deserialization should take care of initializing them if they are missing from the JSON (however, the two representations would not be equal then)

What is your host/environment?

OS java client 3.2/3.3

Do you have any additional context?

I wonder why they are conditionally excluded from the required check. What is the reason for that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions