Skip to content

chore: elasticsearch#914

Merged
SamTV12345 merged 5 commits intomainfrom
feature/elasticsearch
Apr 13, 2026
Merged

chore: elasticsearch#914
SamTV12345 merged 5 commits intomainfrom
feature/elasticsearch

Conversation

@SamTV12345
Copy link
Copy Markdown
Member

No description provided.

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Review Summary by Qodo

Upgrade Elasticsearch client and Docker image to v9

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Upgrade Elasticsearch client from v8 to v9
• Update Elasticsearch Docker image from 7.17.3 to 9.3.3
• Update package dependencies and lock file
• Change import from elasticsearch8 npm alias to @elastic/elasticsearch
Diagram
flowchart LR
  A["elasticsearch8<br/>v8.19.1"] -->|"upgrade"| B["@elastic/elasticsearch<br/>v9.3.4"]
  C["elasticsearch:7.17.3<br/>Docker image"] -->|"upgrade"| D["elasticsearch:9.3.3<br/>Docker image"]
  B -->|"uses"| E["@elastic/transport<br/>v9.3.5"]
  E -->|"uses"| F["secure-json-parse<br/>v4.1.0"]
  E -->|"uses"| G["undici<br/>v7.24.7"]
Loading

Grey Divider

File Changes

1. test/elasticsearch/test.elasticsearch.spec.ts Dependencies +2/-2

Update Elasticsearch import and container version

• Updated import statement from elasticsearch8 to @elastic/elasticsearch
• Upgraded Elasticsearch container version from 7.17.27 to 9.3.3

test/elasticsearch/test.elasticsearch.spec.ts


2. docker-compose.yml ⚙️ Configuration changes +1/-1

Upgrade Elasticsearch Docker image version

• Updated Elasticsearch service image from 7.17.3 to 9.3.3

docker-compose.yml


3. package.json Dependencies +1/-1

Update Elasticsearch client package dependency

• Replaced elasticsearch8 npm alias with direct @elastic/elasticsearch dependency
• Updated version from 8.19.1 to 9.3.4

package.json


View more (1)
4. pnpm-lock.yaml Dependencies +43/-24

Update lock file with Elasticsearch v9 dependencies

• Added @elastic/elasticsearch v9.3.4 as direct dependency
• Removed elasticsearch8 npm alias entry
• Updated @elastic/transport from 8.10.0 to 9.3.5
• Updated secure-json-parse from 3.0.2 to 4.1.0
• Updated undici from 6.21.3 to 7.24.7
• Added libc platform specifiers to various rollup and resolver bindings

pnpm-lock.yaml


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

qodo-free-for-open-source-projects bot commented Apr 12, 2026

Code Review by Qodo

🐞 Bugs (5)   📘 Rule violations (0)   📎 Requirement gaps (0)
🐞\ ⚙ Maintainability (5)

Grey Divider


Action required

1. Missing elasticsearch8 dependency🐞
Description
package.json removes the elasticsearch8 alias but databases/elasticsearch_db.ts still imports
from elasticsearch8, so builds/runtime will fail with a module resolution error.
Code

package.json[40]

+    "@elastic/elasticsearch": "^9.3.4",
Evidence
The PR removes the only dependency that provided the elasticsearch8 import name, but the
Elasticsearch driver still imports Client and MappingTypeMapping from elasticsearch8, which
will no longer resolve.

package.json[25-45]
databases/elasticsearch_db.ts[17-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`databases/elasticsearch_db.ts` still imports from `elasticsearch8` even though the PR removed that alias from `package.json`. This will break TypeScript compilation and runtime module resolution.
## Issue Context
The dependency was renamed from the alias `elasticsearch8` to the real package name `@elastic/elasticsearch`.
## Fix Focus Areas
- databases/elasticsearch_db.ts[17-25]
- package.json[25-45]
## What to change
- Replace `import {Client} from 'elasticsearch8'` with `import {Client} from '@elastic/elasticsearch'`.
- Update the `MappingTypeMapping` type import to the correct path/type for `@elastic/elasticsearch@9` (or replace it with an equivalent local type if the exported type name/path changed).
- Run `pnpm run build` / `pnpm run ts-check` to confirm module resolution and types are correct.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. ES9 breaks type-based migration🐞
Description
The Elasticsearch test suite and migration code rely on ES7 mapping types (type request parameter
and _type in hits), but the PR upgrades the test container to Elasticsearch 9.3.3 where mapping
types are removed, so the ES migration tests (and schema v1→v2 migration logic) will fail.
Code

test/elasticsearch/test.elasticsearch.spec.ts[R32-38]

   //    waits for ES to be ready instead of returning the moment the
   //    container is started (which is what caused the original
   //    "container stopped/paused" failures).
-        container = await new GenericContainer("elasticsearch:7.17.27")
+        container = await new GenericContainer("elasticsearch:9.3.3")
       .withEnvironment({
           "discovery.type": "single-node",
           "ES_JAVA_OPTS": "-Xms512m -Xmx512m",
Evidence
The test file itself documents that it must run against ES7 because it writes legacy type-based
documents; the PR switches the container to ES 9.3.3 anyway. Additionally, the production migration
code constructs keys from _type, which is part of the removed mapping types feature.

test/elasticsearch/test.elasticsearch.spec.ts[20-42]
test/elasticsearch/test.elasticsearch.spec.ts[100-115]
databases/elasticsearch_db.ts[60-73]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Elasticsearch 9.x does not support mapping types, but the test suite and migration code depend on types (`client.index({type: ...})` and reading `_type` from search hits). Switching the container image to `elasticsearch:9.3.3` will cause these tests and migration behaviors to break.
## Issue Context
The tests explicitly state they must stay on ES 7.17.x to verify the legacy schema migration.
## Fix Focus Areas
- test/elasticsearch/test.elasticsearch.spec.ts[20-42]
- test/elasticsearch/test.elasticsearch.spec.ts[100-115]
- databases/elasticsearch_db.ts[60-73]
## What to change
Choose one:
1) **Keep tests/migration coverage:** revert the test container (and any other test infra) back to an ES 7.17.x image.
2) **Drop ES7 migration path:** refactor migration logic + tests to no longer rely on mapping types (including removing `_type` usage and rewriting how legacy keys are derived), then keep ES9.
Make sure `pnpm run test elasticsearch` passes after the change.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Node engine mismatch🐞
Description
The new Elasticsearch client stack requires Node >=20.18.1 via transitive dependencies, but the
package still declares engines.node >=16.20.1, so installs and/or runtime will fail for
currently-supported Node versions.
Code

pnpm-lock.yaml[R3118-3120]

undici@7.24.7:
resolution: {integrity: sha512-H/nlJ/h0ggGC+uRL3ovD+G0i4bqhvsDOpbDv7At5eFLlj2b41L8QliGbnl2H7SnDiYhENphh1tQFJZf+MyfLsQ==}
engines: {node: '>=20.18.1'}
Evidence
package.json claims compatibility with Node 16+, but the lockfile shows dependencies
introduced/updated by this PR require Node 20+ (including undici and @elastic/transport).

package.json[97-100]
pnpm-lock.yaml[241-248]
pnpm-lock.yaml[3118-3121]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`@elastic/elasticsearch@9` brings in dependencies that require Node 20+ (and `undici` specifically requires >=20.18.1), but the package still advertises `engines.node: >=16.20.1`.
## Issue Context
This project is published to npm; incorrect `engines` leads users to install on unsupported Node versions and then hit failures.
## Fix Focus Areas
- package.json[97-100]
- package.json[25-45]
- pnpm-lock.yaml[241-248]
- pnpm-lock.yaml[3118-3121]
## What to change
- Either bump `engines.node` to at least `>=20.18.1` (and consider updating CI to explicitly test that),
- Or pin/downgrade the Elasticsearch client/transport/undici stack to versions that support the currently-declared Node engine range.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (12)
4. Missing elasticsearch8 dependency🐞
Description
package.json removes the elasticsearch8 alias but databases/elasticsearch_db.ts still imports
from elasticsearch8, so builds/runtime will fail with a module resolution error.
Code

package.json[40]

+    "@elastic/elasticsearch": "^9.3.4",
Evidence
The PR removes the only dependency that provided the elasticsearch8 import name, but the
Elasticsearch driver still imports Client and MappingTypeMapping from elasticsearch8, which
will no longer resolve.

package.json[25-45]
databases/elasticsearch_db.ts[17-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`databases/elasticsearch_db.ts` still imports from `elasticsearch8` even though the PR removed that alias from `package.json`. This will break TypeScript compilation and runtime module resolution.
## Issue Context
The dependency was renamed from the alias `elasticsearch8` to the real package name `@elastic/elasticsearch`.
## Fix Focus Areas
- databases/elasticsearch_db.ts[17-25]
- package.json[25-45]
## What to change
- Replace `import {Client} from 'elasticsearch8'` with `import {Client} from '@elastic/elasticsearch'`.
- Update the `MappingTypeMapping` type import to the correct path/type for `@elastic/elasticsearch@9` (or replace it with an equivalent local type if the exported type name/path changed).
- Run `pnpm run build` / `pnpm run ts-check` to confirm module resolution and types are correct.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. ES9 breaks type-based migration🐞
Description
The Elasticsearch test suite and migration code rely on ES7 mapping types (type request parameter
and _type in hits), but the PR upgrades the test container to Elasticsearch 9.3.3 where mapping
types are removed, so the ES migration tests (and schema v1→v2 migration logic) will fail.
Code

test/elasticsearch/test.elasticsearch.spec.ts[R32-38]

    //    waits for ES to be ready instead of returning the moment the
    //    container is started (which is what caused the original
    //    "container stopped/paused" failures).
-        container = await new GenericContainer("elasticsearch:7.17.27")
+        container = await new GenericContainer("elasticsearch:9.3.3")
        .withEnvironment({
            "discovery.type": "single-node",
            "ES_JAVA_OPTS": "-Xms512m -Xmx512m",
Evidence
The test file itself documents that it must run against ES7 because it writes legacy type-based
documents; the PR switches the container to ES 9.3.3 anyway. Additionally, the production migration
code constructs keys from _type, which is part of the removed mapping types feature.

test/elasticsearch/test.elasticsearch.spec.ts[20-42]
test/elasticsearch/test.elasticsearch.spec.ts[100-115]
databases/elasticsearch_db.ts[60-73]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Elasticsearch 9.x does not support mapping types, but the test suite and migration code depend on types (`client.index({type: ...})` and reading `_type` from search hits). Switching the container image to `elasticsearch:9.3.3` will cause these tests and migration behaviors to break.
## Issue Context
The tests explicitly state they must stay on ES 7.17.x to verify the legacy schema migration.
## Fix Focus Areas
- test/elasticsearch/test.elasticsearch.spec.ts[20-42]
- test/elasticsearch/test.elasticsearch.spec.ts[100-115]
- databases/elasticsearch_db.ts[60-73]
## What to change
Choose one:
1) **Keep tests/migration coverage:** revert the test container (and any other test infra) back to an ES 7.17.x image.
2) **Drop ES7 migration path:** refactor migration logic + tests to no longer rely on mapping types (including removing `_type` usage and rewriting how legacy keys are derived), then keep ES9.
Make sure `pnpm run test elasticsearch` passes after the change.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Node engine mismatch🐞
Description
The new Elasticsearch client stack requires Node >=20.18.1 via transitive dependencies, but the
package still declares engines.node >=16.20.1, so installs and/or runtime will fail for
currently-supported Node versions.
Code

pnpm-lock.yaml[R3118-3120]

undici@7.24.7:
resolution: {integrity: sha512-H/nlJ/h0ggGC+uRL3ovD+G0i4bqhvsDOpbDv7At5eFLlj2b41L8QliGbnl2H7SnDiYhENphh1tQFJZf+MyfLsQ==}
engines: {node: '>=20.18.1'}
Evidence
package.json claims compatibility with Node 16+, but the lockfile shows dependencies
introduced/updated by this PR require Node 20+ (including undici and @elastic/transport).

package.json[97-100]
pnpm-lock.yaml[241-248]
pnpm-lock.yaml[3118-3121]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`@elastic/elasticsearch@9` brings in dependencies that require Node 20+ (and `undici` specifically requires >=20.18.1), but the package still advertises `engines.node: >=16.20.1`.
## Issue Context
This project is published to npm; incorrect `engines` leads users to install on unsupported Node versions and then hit failures.
## Fix Focus Areas
- package.json[97-100]
- package.json[25-45]
- pnpm-lock.yaml[241-248]
- pnpm-lock.yaml[3118-3121]
## What to change
- Either bump `engines.node` to at least `>=20.18.1` (and consider updating CI to explicitly test that),
- Or pin/downgrade the Elasticsearch client/transport/undici stack to versions that support the currently-declared Node engine range.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Missing elasticsearch8 dependency🐞
Description
package.json removes the elasticsearch8 alias but databases/elasticsearch_db.ts still imports
from elasticsearch8, so builds/runtime will fail with a module resolution error.
Code

package.json[40]

+    "@elastic/elasticsearch": "^9.3.4",
Evidence
The PR removes the only dependency that provided the elasticsearch8 import name, but the
Elasticsearch driver still imports Client and MappingTypeMapping from elasticsearch8, which
will no longer resolve.

package.json[25-45]
databases/elasticsearch_db.ts[17-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`databases/elasticsearch_db.ts` still imports from `elasticsearch8` even though the PR removed that alias from `package.json`. This will break TypeScript compilation and runtime module resolution.
## Issue Context
The dependency was renamed from the alias `elasticsearch8` to the real package name `@elastic/elasticsearch`.
## Fix Focus Areas
- databases/elasticsearch_db.ts[17-25]
- package.json[25-45]
## What to change
- Replace `import {Client} from 'elasticsearch8'` with `import {Client} from '@elastic/elasticsearch'`.
- Update the `MappingTypeMapping` type import to the correct path/type for `@elastic/elasticsearch@9` (or replace it with an equivalent local type if the exported type name/path changed).
- Run `pnpm run build` / `pnpm run ts-check` to confirm module resolution and types are correct.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. ES9 breaks type-based migration🐞
Description
The Elasticsearch test suite and migration code rely on ES7 mapping types (type request parameter
and _type in hits), but the PR upgrades the test container to Elasticsearch 9.3.3 where mapping
types are removed, so the ES migration tests (and schema v1→v2 migration logic) will fail.
Code

test/elasticsearch/test.elasticsearch.spec.ts[R32-38]

     //    waits for ES to be ready instead of returning the moment the
     //    container is started (which is what caused the original
     //    "container stopped/paused" failures).
-        container = await new GenericContainer("elasticsearch:7.17.27")
+        container = await new GenericContainer("elasticsearch:9.3.3")
         .withEnvironment({
             "discovery.type": "single-node",
             "ES_JAVA_OPTS": "-Xms512m -Xmx512m",
Evidence
The test file itself documents that it must run against ES7 because it writes legacy type-based
documents; the PR switches the container to ES 9.3.3 anyway. Additionally, the production migration
code constructs keys from _type, which is part of the removed mapping types feature.

test/elasticsearch/test.elasticsearch.spec.ts[20-42]
test/elasticsearch/test.elasticsearch.spec.ts[100-115]
databases/elasticsearch_db.ts[60-73]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Elasticsearch 9.x does not support mapping types, but the test suite and migration code depend on types (`client.index({type: ...})` and reading `_type` from search hits). Switching the container image to `elasticsearch:9.3.3` will cause these tests and migration behaviors to break.
## Issue Context
The tests explicitly state they must stay on ES 7.17.x to verify the legacy schema migration.
## Fix Focus Areas
- test/elasticsearch/test.elasticsearch.spec.ts[20-42]
- test/elasticsearch/test.elasticsearch.spec.ts[100-115]
- databases/elasticsearch_db.ts[60-73]
## What to change
Choose one:
1) **Keep tests/migration coverage:** revert the test container (and any other test infra) back to an ES 7.17.x image.
2) **Drop ES7 migration path:** refactor migration logic + tests to no longer rely on mapping types (including removing `_type` usage and rewriting how legacy keys are derived), then keep ES9.
Make sure `pnpm run test elasticsearch` passes after the change.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. Node engine mismatch🐞
Description
The new Elasticsearch client stack requires Node >=20.18.1 via transitive dependencies, but the
package still declares engines.node >=16.20.1, so installs and/or runtime will fail for
currently-supported Node versions.
Code

pnpm-lock.yaml[R3118-3120]

undici@7.24.7:
 resolution: {integrity: sha512-H/nlJ/h0ggGC+uRL3ovD+G0i4bqhvsDOpbDv7At5eFLlj2b41L8QliGbnl2H7SnDiYhENphh1tQFJZf+MyfLsQ==}
 engines: {node: '>=20.18.1'}
Evidence
package.json claims compatibility with Node 16+, but the lockfile shows dependencies
introduced/updated by this PR require Node 20+ (including undici and @elastic/transport).

package.json[97-100]
pnpm-lock.yaml[241-248]
pnpm-lock.yaml[3118-3121]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`@elastic/elasticsearch@9` brings in dependencies that require Node 20+ (and `undici` specifically requires >=20.18.1), but the package still advertises `engines.node: >=16.20.1`.
## Issue Context
This project is published to npm; incorrect `engines` leads users to install on unsupported Node versions and then hit failures.
## Fix Focus Areas
- package.json[97-100]
- package.json[25-45]
- pnpm-lock.yaml[241-248]
- pnpm-lock.yaml[3118-3121]
## What to change
- Either bump `engines.node` to at least `>=20.18.1` (and consider updating CI to explicitly test that),
- Or pin/downgrade the Elasticsearch client/transport/undici stack to versions that support the currently-declared Node engine range.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


10. Missing elasticsearch8 dependency🐞
Description
package.json removes the elasticsearch8 alias but databases/elasticsearch_db.ts still imports
from elasticsearch8, so builds/runtime will fail with a module resolution error.
Code

package.json[40]

+    "@elastic/elasticsearch": "^9.3.4",
Evidence
The PR removes the only dependency that provided the elasticsearch8 import name, but the
Elasticsearch driver still imports Client and MappingTypeMapping from elasticsearch8, which
will no longer resolve.

package.json[25-45]
databases/elasticsearch_db.ts[17-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`databases/elasticsearch_db.ts` still imports from `elasticsearch8` even though the PR removed that alias from `package.json`. This will break TypeScript compilation and runtime module resolution.
## Issue Context
The dependency was renamed from the alias `elasticsearch8` to the real package name `@elastic/elasticsearch`.
## Fix Focus Areas
- databases/elasticsearch_db.ts[17-25]
- package.json[25-45]
## What to change
- Replace `import {Client} from 'elasticsearch8'` with `import {Client} from '@elastic/elasticsearch'`.
- Update the `MappingTypeMapping` type import to the correct path/type for `@elastic/elasticsearch@9` (or replace it with an equivalent local type if the exported type name/path changed).
- Run `pnpm run build` / `pnpm run ts-check` to confirm module resolution and types are correct.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


11. ES9 breaks type-based migration🐞
Description
The Elasticsearch test suite and migration code rely on ES7 mapping types (type request parameter
and _type in hits), but the PR upgrades the test container to Elasticsearch 9.3.3 where mapping
types are removed, so the ES migration tests (and schema v1→v2 migration logic) will fail.
Code

test/elasticsearch/test.elasticsearch.spec.ts[R32-38]

      //    waits for ES to be ready instead of returning the moment the
      //    container is started (which is what caused the original
      //    "container stopped/paused" failures).
-        container = await new GenericContainer("elasticsearch:7.17.27")
+        container = await new GenericContainer("elasticsearch:9.3.3")
          .withEnvironment({
              "discovery.type": "single-node",
              "ES_JAVA_OPTS": "-Xms512m -Xmx512m",
Evidence
The test file itself documents that it must run against ES7 because it writes legacy type-based
documents; the PR switches the container to ES 9.3.3 anyway. Additionally, the production migration
code constructs keys from _type, which is part of the removed mapping types feature.

test/elasticsearch/test.elasticsearch.spec.ts[20-42]
test/elasticsearch/test.elasticsearch.spec.ts[100-115]
databases/elasticsearch_db.ts[60-73]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Elasticsearch 9.x does not support mapping types, but the test suite and migration code depend on types (`client.index({type: ...})` and reading `_type` from search hits). Switching the container image to `elasticsearch:9.3.3` will cause these tests and migration behaviors to break.
## Issue Context
The tests explicitly state they must stay on ES 7.17.x to verify the legacy schema migration.
## Fix Focus Areas
- test/elasticsearch/test.elasticsearch.spec.ts[20-42]
- test/elasticsearch/test.elasticsearch.spec.ts[100-115]
- databases/elasticsearch_db.ts[60-73]
## What to change
Choose one:
1) **Keep tests/migration coverage:** revert the test container (and any other test infra) back to an ES 7.17.x image.
2) **Drop ES7 migration path:** refactor migration logic + tests to no longer rely on mapping types (including removing `_type` usage and rewriting how legacy keys are derived), then keep ES9.
Make sure `pnpm run test elasticsearch` passes after the change.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


12. Node engine mismatch🐞
Description
The new Elasticsearch client stack requires Node >=20.18.1 via transitive dependencies, but the
package still declares engines.node >=16.20.1, so installs and/or runtime will fail for
currently-supported Node versions.
Code

pnpm-lock.yaml[R3118-3120]

undici@7.24.7:
  resolution: {integrity: sha512-H/nlJ/h0ggGC+uRL3ovD+G0i4bqhvsDOpbDv7At5eFLlj2b41L8QliGbnl2H7SnDiYhENphh1tQFJZf+MyfLsQ==}
  engines: {node: '>=20.18.1'}
Evidence
package.json claims compatibility with Node 16+, but the lockfile shows dependencies
introduced/updated by this PR require Node 20+ (including undici and @elastic/transport).

package.json[97-100]
pnpm-lock.yaml[241-248]
pnpm-lock.yaml[3118-3121]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`@elastic/elasticsearch@9` brings in dependencies that require Node 20+ (and `undici` specifically requires >=20.18.1), but the package still advertises `engines.node: >=16.20.1`.
## Issue Context
This project is published to npm; incorrect `engines` leads users to install on unsupported Node versions and then hit failures.
## Fix Focus Areas
- package.json[97-100]
- package.json[25-45]
- pnpm-lock.yaml[241-248]
- pnpm-lock.yaml[3118-3121]
## What to change
- Either bump `engines.node` to at least `>=20.18.1` (and consider updating CI to explicitly test that),
- Or pin/downgrade the Elasticsearch client/transport/undici stack to versions that support the currently-declared Node engine range.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


13. Missing elasticsearch8 dependency🐞
Description
package.json removes the elasticsearch8 alias but databases/elasticsearch_db.ts still imports
from elasticsearch8, so builds/runtime will fail with a module resolution error.
Code

package.json[40]

+    "@elastic/elasticsearch": "^9.3.4",
Evidence
The PR removes the only dependency that provided the elasticsearch8 import name, but the
Elasticsearch driver still imports Client and MappingTypeMapping from elasticsearch8, which
will no longer resolve.

package.json[25-45]
databases/elasticsearch_db.ts[17-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`databases/elasticsearch_db.ts` still imports from `elasticsearch8` even though the PR removed that alias from `package.json`. This will break TypeScript compilation and runtime module resolution.
## Issue Context
The dependency was renamed from the alias `elasticsearch8` to the real package name `@elastic/elasticsearch`.
## Fix Focus Areas
- databases/elasticsearch_db.ts[17-25]
- package.json[25-45]
## What to change
- Replace `import {Client} from 'elasticsearch8'` with `import {Client} from '@elastic/elasticsearch'`.
- Update the `MappingTypeMapping` type import to the correct path/type for `@elastic/elasticsearch@9` (or replace it with an equivalent local type if the exported type name/path changed).
- Run `pnpm run build` / `pnpm run ts-check` to confirm module resolution and types are correct.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


14. ES9 breaks type-based migration🐞
Description
The Elasticsearch test suite and migration code rely on ES7 mapping types (type request parameter
and _type in hits), but the PR upgrades the test container to Elasticsearch 9.3.3 where mapping
types are removed, so the ES migration tests (and schema v1→v2 migration logic) will fail.
Code

test/elasticsearch/test.elasticsearch.spec.ts[R32-38]

       //    waits for ES to be ready instead of returning the moment the
       //    container is started (which is what caused the original
       //    "container stopped/paused" failures).
-        container = await new GenericContainer("elasticsearch:7.17.27")
+        container = await new GenericContainer("elasticsearch:9.3.3")
           .withEnvironment({
               "discovery.type": "single-node",
               "ES_JAVA_OPTS": "-Xms512m -Xmx512m",
Evidence
The test file itself documents that it must run against ES7 because it writes legacy type-based
documents; the PR switches the container to ES 9.3.3 anyway. Additionally, the production migration
code constructs keys from _type, which is part of the removed mapping types feature.

test/elasticsearch/test.elasticsearch.spec.ts[20-42]
test/elasticsearch/test.elasticsearch.spec.ts[100-115]
databases/elasticsearch_db.ts[60-73]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Elasticsearch 9.x does not support mapping types, but the test suite and migration code depend on types (`client.index({type: ...})` and reading `_type` from search hits). Switching the container image to `elasticsearch:9.3.3` will cause these tests and migration behaviors to break.
## Issue Context
The tests explicitly state they must stay on ES 7.17.x to verify the legacy schema migration.
## Fix Focus Areas
- test/elasticsearch/test.elasticsearch.spec.ts[20-42]
- test/elasticsearch/test.elasticsearch.spec.ts[100-115]
- databases/elasticsearch_db.ts[60-73]
## What to change
Choose one:
1) **Keep tests/migration coverage:** revert the test container (and any other test infra) back to an ES 7.17.x image.
2) **Drop ES7 migration path:** refactor migration logic + tests to no longer rely on mapping types (including removing `_type` usage and rewriting how legacy keys are derived), then keep ES9.
Make sure `pnpm run test elasticsearch` passes after the change.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


15. Node engine mismatch🐞
Description
The new Elasticsearch client stack requires Node >=20.18.1 via transitive dependencies, but the
package still declares engines.node >=16.20.1, so installs and/or runtime will fail for
currently-supported Node versions.
Code

pnpm-lock.yaml[R3118-3120]

 undici@7.24.7:
   resolution: {integrity: sha512-H/nlJ/h0ggGC+uRL3ovD+G0i4bqhvsDOpbDv7At5eFLlj2b41L8QliGbnl2H7SnDiYhENphh1tQFJZf+MyfLsQ==}
   engines: {node: '>=20.18.1'}
Evidence
package.json claims compatibility with Node 16+, but the lockfile shows dependencies
introduced/updated by this PR require Node 20+ (including undici and @elastic/transport).

package.json[97-100]
pnpm-lock.yaml[241-248]
pnpm-lock.yaml[3118-3121]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`@elastic/elasticsearch@9` brings in dependencies that require Node 20+ (and `undici` specifically requires >=20.18.1), but the package still advertises `engines.node: >=16.20.1`.
## Issue Context
This project is published to npm; incorrect `engines` leads users to install on unsupported Node versions and then hit failures.
## Fix Focus Areas
- package.json[97-100]
- package.json[25-45]
- pnpm-lock.yaml[241-248]
- pnpm-lock.yaml[3118-3121]
## What to change
- Either bump `engines.node` to at least `>=20.18.1` (and consider updating CI to explicitly test that),
- Or pin/downgrade the Elasticsearch client/transport/undici stack to versions that support the currently-declared Node engine range.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Advisory comments

16. Compose diverges from test setup 🐞
Description
docker-compose.yml upgrades Elasticsearch to 9.3.3 but does not include the extra environment
configuration used by the integration tests, so compose-based local runs won’t mirror the tested
environment.
Code

docker-compose.yml[R11-15]

elasticsearch:
-        image: elasticsearch:7.17.3
+        image: elasticsearch:9.3.3
   ports:
   - 9200:9200
   environment:
Evidence
The compose service only sets discovery.type, while the integration test container explicitly sets
several ES options (including xpack.security.enabled=false). This creates an avoidable mismatch
between local compose usage and CI test behavior.

docker-compose.yml[11-17]
test/elasticsearch/test.elasticsearch.spec.ts[35-42]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docker-compose.yml` is now on ES 9.3.3 but doesn't match the environment configuration the tests rely on.
## Issue Context
Even if compose isn't used in CI, it's typically used for local/dev testing; divergence from the known-good test container config increases setup friction.
## Fix Focus Areas
- docker-compose.yml[11-17]
- test/elasticsearch/test.elasticsearch.spec.ts[35-42]
## What to change
- Consider copying the relevant `.withEnvironment({...})` settings from the test container into `docker-compose.yml` (or document why compose intentionally differs).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


17. Compose diverges from test setup 🐞
Description
docker-compose.yml upgrades Elasticsearch to 9.3.3 but does not include the extra environment
configuration used by the integration tests, so compose-based local runs won’t mirror the tested
environment.
Code

docker-compose.yml[R11-15]

elasticsearch:
-        image: elasticsearch:7.17.3
+        image: elasticsearch:9.3.3
    ports:
    - 9200:9200
    environment:
Evidence
The compose service only sets discovery.type, while the integration test container explicitly sets
several ES options (including xpack.security.enabled=false). This creates an avoidable mismatch
between local compose usage and CI test behavior.

docker-compose.yml[11-17]
test/elasticsearch/test.elasticsearch.spec.ts[35-42]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docker-compose.yml` is now on ES 9.3.3 but doesn't match the environment configuration the tests rely on.
## Issue Context
Even if compose isn't used in CI, it's typically used for local/dev testing; divergence from the known-good test container config increases setup friction.
## Fix Focus Areas
- docker-compose.yml[11-17]
- test/elasticsearch/test.elasticsearch.spec.ts[35-42]
## What to change
- Consider copying the relevant `.withEnvironment({...})` settings from the test container into `docker-compose.yml` (or document why compose intentionally differs).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


18. Compose diverges from test setup 🐞
Description
docker-compose.yml upgrades Elasticsearch to 9.3.3 but does not include the extra environment
configuration used by the integration tests, so compose-based local runs won’t mirror the tested
environment.
Code

docker-compose.yml[R11-15]

 elasticsearch:
-        image: elasticsearch:7.17.3
+        image: elasticsearch:9.3.3
     ports:
     - 9200:9200
     environment:
Evidence
The compose service only sets discovery.type, while the integration test container explicitly sets
several ES options (including xpack.security.enabled=false). This creates an avoidable mismatch
between local compose usage and CI test behavior.

docker-compose.yml[11-17]
test/elasticsearch/test.elasticsearch.spec.ts[35-42]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docker-compose.yml` is now on ES 9.3.3 but doesn't match the environment configuration the tests rely on.
## Issue Context
Even if compose isn't used in CI, it's typically used for local/dev testing; divergence from the known-good test container config increases setup friction.
## Fix Focus Areas
- docker-compose.yml[11-17]
- test/elasticsearch/test.elasticsearch.spec.ts[35-42]
## What to change
- Consider copying the relevant `.withEnvironment({...})` settings from the test container into `docker-compose.yml` (or document why compose intentionally differs).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
19. Compose diverges from test setup 🐞
Description
docker-compose.yml upgrades Elasticsearch to 9.3.3 but does not include the extra environment
configuration used by the integration tests, so compose-based local runs won’t mirror the tested
environment.
Code

docker-compose.yml[R11-15]

  elasticsearch:
-        image: elasticsearch:7.17.3
+        image: elasticsearch:9.3.3
      ports:
      - 9200:9200
      environment:
Evidence
The compose service only sets discovery.type, while the integration test container explicitly sets
several ES options (including xpack.security.enabled=false). This creates an avoidable mismatch
between local compose usage and CI test behavior.

docker-compose.yml[11-17]
test/elasticsearch/test.elasticsearch.spec.ts[35-42]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docker-compose.yml` is now on ES 9.3.3 but doesn't match the environment configuration the tests rely on.
## Issue Context
Even if compose isn't used in CI, it's typically used for local/dev testing; divergence from the known-good test container config increases setup friction.
## Fix Focus Areas
- docker-compose.yml[11-17]
- test/elasticsearch/test.elasticsearch.spec.ts[35-42]
## What to change
- Consider copying the relevant `.withEnvironment({...})` settings from the test container into `docker-compose.yml` (or document why compose intentionally differs).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


20. Compose diverges from test setup 🐞
Description
docker-compose.yml upgrades Elasticsearch to 9.3.3 but does not include the extra environment
configuration used by the integration tests, so compose-based local runs won’t mirror the tested
environment.
Code

docker-compose.yml[R11-15]

   elasticsearch:
-        image: elasticsearch:7.17.3
+        image: elasticsearch:9.3.3
       ports:
       - 9200:9200
       environment:
Evidence
The compose service only sets discovery.type, while the integration test container explicitly sets
several ES options (including xpack.security.enabled=false). This creates an avoidable mismatch
between local compose usage and CI test behavior.

docker-compose.yml[11-17]
test/elasticsearch/test.elasticsearch.spec.ts[35-42]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docker-compose.yml` is now on ES 9.3.3 but doesn't match the environment configuration the tests rely on.
## Issue Context
Even if compose isn't used in CI, it's typically used for local/dev testing; divergence from the known-good test container config increases setup friction.
## Fix Focus Areas
- docker-compose.yml[11-17]
- test/elasticsearch/test.elasticsearch.spec.ts[35-42]
## What to change
- Consider copying the relevant `.withEnvironment({...})` settings from the test container into `docker-compose.yml` (or document why compose intentionally differs).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Upgrade Elasticsearch client and dependencies to v9

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Upgrade Elasticsearch client from v8 to v9
• Update Elasticsearch container image to 9.3.3
• Update dependencies for transport and security packages
• Modernize test infrastructure with latest client version
Diagram
flowchart LR
  A["elasticsearch8<br/>v8.19.1"] -->|"upgrade"| B["@elastic/elasticsearch<br/>v9.3.4"]
  C["elasticsearch:7.17.27<br/>container"] -->|"upgrade"| D["elasticsearch:9.3.3<br/>container"]
  B -->|"uses"| E["@elastic/transport<br/>v9.3.5"]
  E -->|"uses"| F["secure-json-parse<br/>v4.1.0"]
  E -->|"uses"| G["undici<br/>v7.24.7"]
Loading

Grey Divider

File Changes

1. test/elasticsearch/test.elasticsearch.spec.ts Dependencies +2/-2

Update Elasticsearch client import and container version

• Updated import statement from elasticsearch8 to @elastic/elasticsearch
• Upgraded Elasticsearch container image from 7.17.27 to 9.3.3
• Maintains test infrastructure compatibility with new client version

test/elasticsearch/test.elasticsearch.spec.ts


2. docker-compose.yml ⚙️ Configuration changes +1/-1

Upgrade Elasticsearch Docker image version

• Updated Elasticsearch service image from 7.17.3 to 9.3.3
• Maintains existing port and environment configuration

docker-compose.yml


3. package.json Dependencies +1/-1

Update Elasticsearch package dependency to v9

• Replaced elasticsearch8 npm alias with direct @elastic/elasticsearch dependency
• Updated version from 8.19.1 to 9.3.4
• Simplified dependency declaration by removing npm alias pattern

package.json


View more (1)
4. pnpm-lock.yaml Dependencies +43/-24

Update lock file with Elasticsearch v9 and transitive dependencies

• Added @elastic/elasticsearch@9.3.4 as direct dependency
• Updated @elastic/transport from 8.10.0 to 9.3.5
• Updated secure-json-parse from 3.0.2 to 4.1.0
• Updated undici from 6.21.3 to 7.24.7
• Removed old elasticsearch8 npm alias entry
• Added libc specifications for various platform-specific bindings

pnpm-lock.yaml


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Apr 12, 2026

Code Review by Qodo

🐞 Bugs (4)   📘 Rule violations (0)   📎 Requirement gaps (0)   🎨 UX Issues (0)
🐞\ ≡ Correctness (2) ☼ Reliability (1) ⚙ Maintainability (1)

Grey Divider


Action required

1. Missing elasticsearch8 dependency 🐞
Description
package.json removes the elasticsearch8 alias but databases/elasticsearch_db.ts still imports
from elasticsearch8, so builds/runtime will fail with a module resolution error.
Code

package.json[40]

+    "@elastic/elasticsearch": "^9.3.4",
Evidence
The PR removes the only dependency that provided the elasticsearch8 import name, but the
Elasticsearch driver still imports Client and MappingTypeMapping from elasticsearch8, which
will no longer resolve.

package.json[25-45]
databases/elasticsearch_db.ts[17-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`databases/elasticsearch_db.ts` still imports from `elasticsearch8` even though the PR removed that alias from `package.json`. This will break TypeScript compilation and runtime module resolution.

## Issue Context
The dependency was renamed from the alias `elasticsearch8` to the real package name `@elastic/elasticsearch`.

## Fix Focus Areas
- databases/elasticsearch_db.ts[17-25]
- package.json[25-45]

## What to change
- Replace `import {Client} from 'elasticsearch8'` with `import {Client} from '@elastic/elasticsearch'`.
- Update the `MappingTypeMapping` type import to the correct path/type for `@elastic/elasticsearch@9` (or replace it with an equivalent local type if the exported type name/path changed).
- Run `pnpm run build` / `pnpm run ts-check` to confirm module resolution and types are correct.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. ES9 breaks type-based migration 🐞
Description
The Elasticsearch test suite and migration code rely on ES7 mapping types (type request parameter
and _type in hits), but the PR upgrades the test container to Elasticsearch 9.3.3 where mapping
types are removed, so the ES migration tests (and schema v1→v2 migration logic) will fail.
Code

test/elasticsearch/test.elasticsearch.spec.ts[R32-38]

        //    waits for ES to be ready instead of returning the moment the
        //    container is started (which is what caused the original
        //    "container stopped/paused" failures).
-        container = await new GenericContainer("elasticsearch:7.17.27")
+        container = await new GenericContainer("elasticsearch:9.3.3")
            .withEnvironment({
                "discovery.type": "single-node",
                "ES_JAVA_OPTS": "-Xms512m -Xmx512m",
Evidence
The test file itself documents that it must run against ES7 because it writes legacy type-based
documents; the PR switches the container to ES 9.3.3 anyway. Additionally, the production migration
code constructs keys from _type, which is part of the removed mapping types feature.

test/elasticsearch/test.elasticsearch.spec.ts[20-42]
test/elasticsearch/test.elasticsearch.spec.ts[100-115]
databases/elasticsearch_db.ts[60-73]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Elasticsearch 9.x does not support mapping types, but the test suite and migration code depend on types (`client.index({type: ...})` and reading `_type` from search hits). Switching the container image to `elasticsearch:9.3.3` will cause these tests and migration behaviors to break.

## Issue Context
The tests explicitly state they must stay on ES 7.17.x to verify the legacy schema migration.

## Fix Focus Areas
- test/elasticsearch/test.elasticsearch.spec.ts[20-42]
- test/elasticsearch/test.elasticsearch.spec.ts[100-115]
- databases/elasticsearch_db.ts[60-73]

## What to change
Choose one:
1) **Keep tests/migration coverage:** revert the test container (and any other test infra) back to an ES 7.17.x image.
2) **Drop ES7 migration path:** refactor migration logic + tests to no longer rely on mapping types (including removing `_type` usage and rewriting how legacy keys are derived), then keep ES9.

Make sure `pnpm run test elasticsearch` passes after the change.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Node engine mismatch 🐞
Description
The new Elasticsearch client stack requires Node >=20.18.1 via transitive dependencies, but the
package still declares engines.node >=16.20.1, so installs and/or runtime will fail for
currently-supported Node versions.
Code

pnpm-lock.yaml[R3118-3120]

  undici@7.24.7:
    resolution: {integrity: sha512-H/nlJ/h0ggGC+uRL3ovD+G0i4bqhvsDOpbDv7At5eFLlj2b41L8QliGbnl2H7SnDiYhENphh1tQFJZf+MyfLsQ==}
    engines: {node: '>=20.18.1'}
Evidence
package.json claims compatibility with Node 16+, but the lockfile shows dependencies
introduced/updated by this PR require Node 20+ (including undici and @elastic/transport).

package.json[97-100]
pnpm-lock.yaml[241-248]
pnpm-lock.yaml[3118-3121]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`@elastic/elasticsearch@9` brings in dependencies that require Node 20+ (and `undici` specifically requires >=20.18.1), but the package still advertises `engines.node: >=16.20.1`.

## Issue Context
This project is published to npm; incorrect `engines` leads users to install on unsupported Node versions and then hit failures.

## Fix Focus Areas
- package.json[97-100]
- package.json[25-45]
- pnpm-lock.yaml[241-248]
- pnpm-lock.yaml[3118-3121]

## What to change
- Either bump `engines.node` to at least `>=20.18.1` (and consider updating CI to explicitly test that),
- Or pin/downgrade the Elasticsearch client/transport/undici stack to versions that support the currently-declared Node engine range.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Advisory comments

4. Compose diverges from test setup 🐞
Description
docker-compose.yml upgrades Elasticsearch to 9.3.3 but does not include the extra environment
configuration used by the integration tests, so compose-based local runs won’t mirror the tested
environment.
Code

docker-compose.yml[R11-15]

    elasticsearch:
-        image: elasticsearch:7.17.3
+        image: elasticsearch:9.3.3
        ports:
        - 9200:9200
        environment:
Evidence
The compose service only sets discovery.type, while the integration test container explicitly sets
several ES options (including xpack.security.enabled=false). This creates an avoidable mismatch
between local compose usage and CI test behavior.

docker-compose.yml[11-17]
test/elasticsearch/test.elasticsearch.spec.ts[35-42]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docker-compose.yml` is now on ES 9.3.3 but doesn't match the environment configuration the tests rely on.

## Issue Context
Even if compose isn't used in CI, it's typically used for local/dev testing; divergence from the known-good test container config increases setup friction.

## Fix Focus Areas
- docker-compose.yml[11-17]
- test/elasticsearch/test.elasticsearch.spec.ts[35-42]

## What to change
- Consider copying the relevant `.withEnvironment({...})` settings from the test container into `docker-compose.yml` (or document why compose intentionally differs).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@JohnMcLear
Copy link
Copy Markdown
Member

Good start, still a lot to do :)

"cli-table3": "^0.6.5",
"dirty-ts": "^1.1.8",
"elasticsearch8": "npm:@elastic/elasticsearch@^8.19.1",
"@elastic/elasticsearch": "^9.3.4",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought this is better. Idk why this was renamed like this before

// We deliberately stay on Elasticsearch 7.17.x because the
// 'migration to schema v2 / existing data' tests below intentionally
// write data in the legacy ES7 type-based schema (via client.index
// with `type:`) to verify the v1 -> v2 migration code path. ES 8
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the comment because we now use the modern schema

@JohnMcLear
Copy link
Copy Markdown
Member

Nice!

@SamTV12345
Copy link
Copy Markdown
Member Author

Nice!

Yes do we need to do something else? Otherwise I think we have now a full elasticsearch v9 support

@JohnMcLear
Copy link
Copy Markdown
Member

I think qodo has some complaints, if they are invalid just flag them as invalid and LGTM :)

@SamTV12345
Copy link
Copy Markdown
Member Author

I think qodo has some complaints, if they are invalid just flag them as invalid and LGTM :)

I think I fixed all of them. Thanks :)

@SamTV12345 SamTV12345 merged commit 57041bc into main Apr 13, 2026
11 checks passed
@SamTV12345 SamTV12345 deleted the feature/elasticsearch branch April 13, 2026 17:18
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

Successfully merging this pull request may close these issues.

2 participants