Skip to content
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

Notnull check on template is blocking the creation of composite template request #1281

Open
nibin opened this issue Nov 10, 2024 · 0 comments

Comments

@nibin
Copy link

nibin commented Nov 10, 2024

Hi Team,

Please find the below code -

https://github.com/opensearch-project/opensearch-java/blame/bb0fa12098ed3ef8b785a4560d6d962b2726a0d2/java-client/src/main/java/org/opensearch/client/opensearch/cluster/PutComponentTemplateRequest.java#L107

this.template = ApiTypeHelper.requireNonNull(builder.template, this, "template");

This check is not needed and the whole purpose for us is to create the template object using builder. Infact see the sample code where "template" is not explicitly created part of the builder.

  1. https://github.com/opensearch-project/opensearch-java/blob/main/samples/src/main/java/org/opensearch/client/samples/IndexTemplates.java#L49
  2. https://github.com/opensearch-project/opensearch-java/blob/main/samples/src/main/java/org/opensearch/client/samples/IndexTemplates.java#L69

Currently due to this check, a requireNonNull error is thrown and we cannot use the PutComponentTemplateRequest object in building component templates via RestClient java api.

Error below
Exception in thread "main" org.opensearch.client.util.MissingRequiredPropertyException: Missing required property 'PutComponentTemplateRequest.template' at org.opensearch.client.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:90) at org.opensearch.client.opensearch.cluster.PutComponentTemplateRequest.<init>(PutComponentTemplateRequest.java:107) at org.opensearch.client.opensearch.cluster.PutComponentTemplateRequest.<init>(PutComponentTemplateRequest.java:67) at org.opensearch.client.opensearch.cluster.PutComponentTemplateRequest$Builder.build(PutComponentTemplateRequest.java:464) at org.opensearch.client.opensearch.cluster.PutComponentTemplateRequest$Builder.build(PutComponentTemplateRequest.java:262) at org.opensearch.client.opensearch.cluster.PutComponentTemplateRequest.of(PutComponentTemplateRequest.java:113) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323) at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrap.invoke(StaticMetaMethodSite.java:131) at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:89) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139) at App.main(App.groovy:82)

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

No branches or pull requests

1 participant