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

[BUG] createPit client method is throwing ResponseError: parse_exception: [parse_exception] Reason: request body is required #746

Closed
toyaokeke opened this issue Apr 4, 2024 · 4 comments

Comments

@toyaokeke
Copy link

toyaokeke commented Apr 4, 2024

What is the bug?

the createPit method is throwing different errors, even though I am following the expected specifications from the opensearch user guide

I've also looked the source code for this method

  • throws ResponseError: parse_exception: [parse_exception] Reason: request body is required if body is not passed as an input
  • throws ResponseError: illegal_argument_exception: [illegal_argument_exception] Reason: request [/tests_func/_search/point_in_time] contains unrecognized parameters: [expand_wildcards], [keep_alive] when body, keep_alive and expand_wilcards are passed
  • throws ConfigurationError: Missing required parameter: keep_alive if keep_alive parameter is removed

How can one reproduce the bug?

sample TS file

import { Client } from '@opensearch-project/opensearch';

const INDEX_NAME = 'tests_func';

const esClient = new Client({
    node: `http://test_func_elastic:9200`,
    maxRetries: 1,
    requestTimeout: 60000,
});
await esClient.indices.create({ index: INDEX_NAME });
await esClient.createPit({ index: INDEX_NAME, keep_alive: '10m' });

What is the expected behavior?

expect the createPit method to create a PIT using my input params

What is your host/environment?

OS: macOs Sonoma 14.2.1
Running a containerized application (see the Dockerfile in the additional context)
Docker version 20.10.22
Opensearch image 2.11.1 from AWS Public ECR

Do you have any screenshots?

If I remove body which is not a param in the SDK, I get this error
image

if I remove keep_alive which is required I get this error
image

If I add keep_alive and body (and expand_wilcards, which is also a valid parameter), I get this error
image

Do you have any additional context?

Dockerfile

FROM public.ecr.aws/opensearchproject/opensearch:2.11.1
RUN /usr/share/opensearch/bin/opensearch-plugin remove opensearch-security && \
    /usr/share/opensearch/bin/opensearch-plugin install --batch analysis-kuromoji && \
    /usr/share/opensearch/bin/opensearch-plugin install --batch analysis-smartcn && \
    /usr/share/opensearch/bin/opensearch-plugin install --batch analysis-nori
# Openserach docker setup can be followed in these links
# https://opensearch.org/docs/latest/install-and-configure/install-opensearch/docker/
# https://opensearch.org/docs/latest/install-and-configure/install-opensearch/index/#important-settings
ENV cluster.name=docker-msproduct-cluster \
    network.host=0.0.0.0 \
    node.name=ms-product-elasticsearch \
    # Memory lock check.
    # see: https://www.elastic.co/guide/en/elasticsearch/reference/master/_memory_lock_check.html
    bootstrap.memory_lock=true \
    discovery.type=single-node \
    # helps functional tests not fail randomly due to low available disk space
    cluster.routing.allocation.disk.threshold_enabled=true \
    cluster.routing.allocation.disk.watermark.low=500mb \
    cluster.routing.allocation.disk.watermark.high=300mb \
    cluster.routing.allocation.disk.watermark.flood_stage=200mb \
    action.auto_create_index=false \
    path.repo=backup

package.json (simplified)

{
    "dependencies": {
        "@opensearch-project/opensearch": "^2.6.0"
    },
    "engines": {
        "node": ">= 20.8.0",
        "npm": ">= 10.1.0"
    }
}
@nhtruong
Copy link
Collaborator

I don't get that error and could create a PIT just fine:

cd .ci/opensearch
export OPENSEARCH_VERSION=2.11.0
docker compose up -d
const { Client } = require('@opensearch-project/opensearch');
const client = new Client({node: 'http://localhost:9200'});

const start = async () => {
const movies = 'movies';
await client.indices.create({ index: movies });
console.log(await client.createPit({ index: movies, keep_alive: '10m' }));
{
  body: {
    pit_id: 's4GCQQEGbW92aWVzFjFXeHIwZklXVDktNTRxN3pHajA3YkEAFl9rVFRKTWlvUkFxSUxHQnpWYUdwWEEAAAAAAAAAAAIWT3dscTBuN09SazItMm84TEJ4NXNvdwEWMVd4cjBmSVdUOS01NHE3ekdqMDdiQQAA',
    _shards: { total: 1, successful: 1, skipped: 0, failed: 0 },
    creation_time: 1712796391467
  },
  statusCode: 200,
  headers: {
    'content-type': 'application/json; charset=UTF-8',
    'content-length': '259'
  },
  meta: {
    context: null,
    request: { params: [Object], options: {}, id: 7 },
    name: 'opensearch-js',
    connection: {
      url: 'http://localhost:9200/',
      id: 'http://localhost:9200/',
      headers: {},
      deadCount: 0,
      resurrectTimeout: 0,
      _openRequests: 0,
      status: 'alive',
      roles: [Object]
    },
    attempts: 0,
    aborted: false
  }
}

@toyaokeke
Copy link
Author

closing this issue, I managed to resolve the issue

@dblock
Copy link
Member

dblock commented Apr 17, 2024

@toyaokeke What was your issue (for the next person)?

@toyaokeke
Copy link
Author

it seems like I may have been using an incorrect Dockerfile in my application. The Dockerfile iI shared was using Opensearch 2.11, but in my local tests I seemed to have been mistakenly using Elasticsearch 7.9, which does not support point in time

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

No branches or pull requests

3 participants