Skip to content

putGeoipDatabase without body parameter returns an error #2482

@SoniaSanzV

Description

@SoniaSanzV

🐛 Bug report

ES js client version: 8.15

When creating an ip_location database with the JS client, it fails for non maxmind database types. This does not happen if we pass the body, which is marked as deprecated.

For example, using ipinfo type as example, this is working as expected:

// Our code:
await clusterClient.asCurrentUser.ingest.putGeoipDatabase({
          id: normalizedDatabaseName,
          body: serializedDatabase,
        });

// That would be, for example:
{ id: 'standard_privacy', body: { name: 'standard_privacy', ipinfo: {} } }

But this is not working unless the type is maxmind.

// Our code:
await clusterClient.asCurrentUser.ingest.putGeoipDatabase({
          id: normalizedDatabaseName,
          name: serializedDatabase.name
        });

// That would be, for example (there is not parameter for the type, in this case `ipinfo`):
 {
  id: 'standard_privacy',
  name: 'standard_privacy'
}

And this is the response that I'm receiving.

{
    "statusCode": 400,
    "error": "Bad Request",
    "message": "Failed to build [database] after last required field arrived",
    "attributes": {
        "error": {
            "root_cause": [
                {
                    "type": "x_content_parse_exception",
                    "reason": "Failed to build [database] after last required field arrived"
                }
            ],
            "type": "x_content_parse_exception",
            "reason": "Failed to build [database] after last required field arrived",
            "caused_by": {
                "type": "illegal_argument_exception",
                "reason": "Exactly one provider object must be specified, but [0] were found"
            }
        },
        "causes": [
            "Exactly one provider object must be specified, but [0] were found"
        ]
    }
}

To reproduce

Create a database with the client using a type but maxmind

await clusterClient.asCurrentUser.ingest.putGeoipDatabase({
          id: 'standard_privacy',
          name: 'standard_privacy'
        });

Expected behavior

I can create a database using the client

Node.js version

20.15.1

@elastic/elasticsearch version

8.15

Operating system

macOs

Any other relevant environment information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions