Skip to content

fix: use underscores in ES connector filenames to avoid build exclusion#245326

Merged
Kiryous merged 9 commits intoelastic:mainfrom
shahargl:bugfix/elasticsearch-test-endpoints
Dec 5, 2025
Merged

fix: use underscores in ES connector filenames to avoid build exclusion#245326
Kiryous merged 9 commits intoelastic:mainfrom
shahargl:bugfix/elasticsearch-test-endpoints

Conversation

@shahargl
Copy link
Copy Markdown
Contributor

@shahargl shahargl commented Dec 4, 2025

close https://github.com/elastic/security-team/issues/14960

Summary

Fixes a runtime error on Kibana Serverless where the @kbn/workflows module fails to load due to a missing file.

Problem

Files with .test. in their filename are excluded from production builds by the excludeFileByTags function in build_packages_task.ts. The Elasticsearch query_rules.test API endpoint was being excluded because its generated filename (elasticsearch.query_rules.test.gen.ts) contained .test., which triggered the build exclusion rule.

This caused the following runtime error on Serverless:

Error: Cannot find module './elasticsearch.query_rules.test.gen'
Require stack:
- /usr/share/kibana/node_modules/@kbn/workflows/spec/elasticsearch/generated/index.js

Solution

Updated the ES connector generator to use underscores instead of dots in filenames while keeping the runtime type field unchanged for compatibility.

Before After
elasticsearch.query_rules.test.gen.ts elasticsearch.query_rules_test.gen.ts
❌ Excluded by build ✅ Included in build

The type field inside each contract (e.g., 'elasticsearch.query_rules.test') remains unchanged, so all runtime lookups continue to work correctly.

Testing

  • Built Kibana locally with yarn build --skip-os-packages
  • Verified the file exists in the serverless build output
  • Verified the @kbn/workflows module loads successfully from the built distribution

Changes

  • Modified generate_es_connectors.ts to use underscores in generated filenames
  • Regenerated all ES connector files with the new naming convention

Risk

Low - This is a filename-only change. The runtime behavior and API contracts remain identical.

Files with '.test.' in the name are excluded from production builds.
The elasticsearch.query_rules.test API endpoint was being excluded because
its generated filename contained '.test.' which triggered the exclusion rule.

This changes the generator to use underscores instead of dots in filenames
(e.g., elasticsearch.query_rules_test.gen.ts instead of
elasticsearch.query_rules.test.gen.ts) while keeping the runtime 'type' field
unchanged for compatibility.
@shahargl shahargl requested a review from a team as a code owner December 4, 2025 23:20
@shahargl shahargl added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Dec 4, 2025
@Kiryous Kiryous added the Team:One Workflow Team label for One Workflow (Workflow automation) label Dec 5, 2025
@Kiryous Kiryous enabled auto-merge (squash) December 5, 2025 08:56
@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

Failed CI Steps

History

@Kiryous Kiryous merged commit f2f1e5f into elastic:main Dec 5, 2025
12 checks passed
wildemat pushed a commit to wildemat/kibana that referenced this pull request Dec 5, 2025
…on (elastic#245326)

close elastic/security-team#14960

## Summary

Fixes a runtime error on Kibana Serverless where the `@kbn/workflows`
module fails to load due to a missing file.

## Problem

Files with `.test.` in their filename are excluded from production
builds by the `excludeFileByTags` function in `build_packages_task.ts`.
The Elasticsearch `query_rules.test` API endpoint was being excluded
because its generated filename (`elasticsearch.query_rules.test.gen.ts`)
contained `.test.`, which triggered the build exclusion rule.

This caused the following runtime error on Serverless:

```
Error: Cannot find module './elasticsearch.query_rules.test.gen'
Require stack:
- /usr/share/kibana/node_modules/@kbn/workflows/spec/elasticsearch/generated/index.js
```

## Solution

Updated the ES connector generator to use underscores instead of dots in
filenames while keeping the runtime `type` field unchanged for
compatibility.

| Before | After |
|--------|-------|
| `elasticsearch.query_rules.test.gen.ts` |
`elasticsearch.query_rules_test.gen.ts` |
| ❌ Excluded by build | ✅ Included in build |

The `type` field inside each contract (e.g.,
`'elasticsearch.query_rules.test'`) remains unchanged, so all runtime
lookups continue to work correctly.

## Testing

- [x] Built Kibana locally with `yarn build --skip-os-packages`
- [x] Verified the file exists in the serverless build output
- [x] Verified the `@kbn/workflows` module loads successfully from the
built distribution

## Changes

- Modified `generate_es_connectors.ts` to use underscores in generated
filenames
- Regenerated all ES connector files with the new naming convention

## Risk

Low - This is a filename-only change. The runtime behavior and API
contracts remain identical.

---------

Co-authored-by: Kirill Chernakov <kirill.chernakov@elastic.co>
Co-authored-by: Kirill Chernakov <yakiryous@gmail.com>
JordanSh pushed a commit to JordanSh/kibana that referenced this pull request Dec 9, 2025
…on (elastic#245326)

close elastic/security-team#14960

## Summary

Fixes a runtime error on Kibana Serverless where the `@kbn/workflows`
module fails to load due to a missing file.

## Problem

Files with `.test.` in their filename are excluded from production
builds by the `excludeFileByTags` function in `build_packages_task.ts`.
The Elasticsearch `query_rules.test` API endpoint was being excluded
because its generated filename (`elasticsearch.query_rules.test.gen.ts`)
contained `.test.`, which triggered the build exclusion rule.

This caused the following runtime error on Serverless:

```
Error: Cannot find module './elasticsearch.query_rules.test.gen'
Require stack:
- /usr/share/kibana/node_modules/@kbn/workflows/spec/elasticsearch/generated/index.js
```

## Solution

Updated the ES connector generator to use underscores instead of dots in
filenames while keeping the runtime `type` field unchanged for
compatibility.

| Before | After |
|--------|-------|
| `elasticsearch.query_rules.test.gen.ts` |
`elasticsearch.query_rules_test.gen.ts` |
| ❌ Excluded by build | ✅ Included in build |

The `type` field inside each contract (e.g.,
`'elasticsearch.query_rules.test'`) remains unchanged, so all runtime
lookups continue to work correctly.

## Testing

- [x] Built Kibana locally with `yarn build --skip-os-packages`
- [x] Verified the file exists in the serverless build output
- [x] Verified the `@kbn/workflows` module loads successfully from the
built distribution

## Changes

- Modified `generate_es_connectors.ts` to use underscores in generated
filenames
- Regenerated all ES connector files with the new naming convention

## Risk

Low - This is a filename-only change. The runtime behavior and API
contracts remain identical.

---------

Co-authored-by: Kirill Chernakov <kirill.chernakov@elastic.co>
Co-authored-by: Kirill Chernakov <yakiryous@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:One Workflow Team label for One Workflow (Workflow automation) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants