opensearch-project / opensearch-project/opensearch-java

[BUG] ISM API - Put Policies: `java.lang.RuntimeException: Jackson exception: Numeric value out of range of int (-2147483648 - 2147483647)`

Open
#1,717 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
165
Forks
250
Avg merge
1d 18h
Merged PRs (30d)
26

Description

What is the bug?

When attempting to make a PutPolicyRequest, the following exception is thrown:

java.lang.RuntimeException: Jackson exception: Numeric value (1755915614485) out of range of int (-2147483648 - 2147483647)
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 342]

However, the policy is saved. It appears that some numeric value, likely a timestamp, is triggering a validation error. I am currently not specifying any time values explicitly.

How can one reproduce the bug?

I tried to use the ISM code to add a simply policy based on this example:
https://docs.opensearch.org/latest/im-plugin/ism/policies/#sample-policy-with-ism-template-for-auto-rollover

A snippet of my code is below:

IsmTemplate getIsmTemplate() {
      return IsmTemplate.builder()
          .lastUpdatedTime(1)
          .indexPatterns(getIndexMatchingPattern())
          .build();
}

List<States> getStates() {
      var rollover = Action.builder()
          .rollover(ActionRollover.builder()
              .minDocCount(MAX_RECORDS)
              .build())
          .build();
      return List.of(
          States.builder()
              .name(IndexState.WRITEABLE.name)
              .actions(rollover)
              .build()
      );
}

/* ... */
var p = Policy.builder()
            .states(getStates())
          .policyId(<id>)
          .defaultState(IndexState.WRITEABLE.name)
          .ismTemplate(getIsmTemplate());

var policyReq = PutPoliciesRequest.builder()
          .policy(_p -> p)
          .policyId(r.getId())
          .build();
var policyRes = client.ism().putPolicies(policyReq); // THROWS HERE
What is the expected behavior?

The expected behavior would be that client.ism().putPolicies should not throw.

What is your host/environment?

Windows 11

Do you have any screenshots?

Stacktrace of the exception showing that the call to putPolicies fails:

Image
Do you have any additional context?

The number that is out of range seems to be a unix epoch description. Perhaps one of the fields in the request object needs to be changed to a type that can fit the number?

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing PutPoliciesRequest and the ISM policy model through the Java client’s Jackson handling, focusing on the timestamp-like value reported in the exception. Reproduce the sample policy request, identify the field whose type cannot hold the epoch value, and add or update a regression test showing that client.ism().putPolicies no longer throws.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.