ELK version: 8.5.3
yarn version: 1.22.19
So I'm developing a Kibana plugin and whenever I need to call @kbn/config-schema
inside of it, I get the fatal error on Kibana startup after installation of said plugin (pasted below).
It's worth noting that yarn build
does not generate any errors, it occurs only after successful installation on a fresh and clean Kibana (installed using the docker run --name NAME --net NET -p 63001:5601 docker.elastic.co/kibana/kibana:8.5.3
command).
So far I've tried the following steps:
- Verified and reinstalled dependencies with
yarn kbn clean/reset
(tried both options) andyarn kbn bootstrap
- Manually checked the tsconfig.json inside of a plugin and verified that the
@kbn/config-schema
exists in both development and runtime environment. - Verified the code, so it calls config-schema correctly.
Currently I'm out of ideas what could be possibly causing this error, I will be very thankful for any possible solutions or at least tips what should I do next.
[2024-02-16T13:26:51.393+00:00][FATAL][root] Error: Cannot find module '../../../../packages/kbn-config-schema'
Require stack:
- /usr/share/kibana/plugins/kpiFix/server/routes/index.js
- /usr/share/kibana/plugins/kpiFix/server/plugin.js
- /usr/share/kibana/plugins/kpiFix/server/index.js
- /usr/share/kibana/src/core/server/plugins/plugin.js
- /usr/share/kibana/src/core/server/plugins/discovery/plugins_discovery.js
- /usr/share/kibana/src/core/server/plugins/discovery/index.js
- /usr/share/kibana/src/core/server/plugins/plugins_service.js
- /usr/share/kibana/src/core/server/plugins/index.js
- /usr/share/kibana/src/core/server/server.js
- /usr/share/kibana/src/core/server/root/index.js
- /usr/share/kibana/src/core/server/bootstrap.js
- /usr/share/kibana/src/core/server/index.js
- /usr/share/kibana/src/cli/serve/serve.js
- /usr/share/kibana/src/cli/cli.js
- /usr/share/kibana/src/cli/dist.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:81:25)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/usr/share/kibana/plugins/kpiFix/server/routes/index.ts:4:1)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Module.require (node:internal/modules/cjs/loader:1057:19)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/usr/share/kibana/plugins/kpiFix/server/plugin.ts:10:1)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Module.require (node:internal/modules/cjs/loader:1057:19)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/usr/share/kibana/plugins/kpiFix/server/index.ts:2:1)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Module.require (node:internal/modules/cjs/loader:1057:19)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
at require (node:internal/modules/cjs/helpers:103:18)
at PluginWrapper.getConfigDescriptor (/usr/share/kibana/src/core/server/plugins/plugin.js:147:30)
at PluginsService.handleDiscoveredPlugins (/usr/share/kibana/src/core/server/plugins/plugins_service.js:194:39)
at PluginsService.discover (/usr/share/kibana/src/core/server/plugins/plugins_service.js:78:5)
at Server.preboot (/usr/share/kibana/src/core/server/server.js:182:30)
at Root.preboot (/usr/share/kibana/src/core/server/root/index.js:48:14)
at bootstrap (/usr/share/kibana/src/core/server/bootstrap.js:99:9)
at Command.<anonymous> (/usr/share/kibana/src/cli/serve/serve.js:216:5)
FATAL Error: Cannot find module '../../../../packages/kbn-config-schema'
Require stack:
- /usr/share/kibana/plugins/kpiFix/server/routes/index.js
- /usr/share/kibana/plugins/kpiFix/server/plugin.js
- /usr/share/kibana/plugins/kpiFix/server/index.js
- /usr/share/kibana/src/core/server/plugins/plugin.js
- /usr/share/kibana/src/core/server/plugins/discovery/plugins_discovery.js
- /usr/share/kibana/src/core/server/plugins/discovery/index.js
- /usr/share/kibana/src/core/server/plugins/plugins_service.js
- /usr/share/kibana/src/core/server/plugins/index.js
- /usr/share/kibana/src/core/server/server.js
- /usr/share/kibana/src/core/server/root/index.js
- /usr/share/kibana/src/core/server/bootstrap.js
- /usr/share/kibana/src/core/server/index.js
- /usr/share/kibana/src/cli/serve/serve.js
- /usr/share/kibana/src/cli/cli.js
- /usr/share/kibana/src/cli/dist.js
Additionally, I paste the code fragment from the plugin that in my belief causes this error.
plugin/server/routes/index.ts
import { schema } from '@kbn/config-schema';
const requestBodySchema = schema.object({
index: schema.string(),
script: schema.object({
source: schema.string(),
params: schema.object({
fieldName: schema.string(),
fieldValue: schema.string(),
}),
lang: schema.string(),
}),
query: schema.object({
range: schema.object({
"@timestamp": schema.object({
format: schema.string(),
gte: schema.string(),
lte: schema.string(),
}),
}),
}),
});
....
router.post({
path: '/api/kpi_fix/_update_by_query',
validate: {
body: requestBodySchema,
},
}, async (context, request, response) => {
try {
const { index, script, query } = request.body;
const esClient = context.core.elasticsearch.client.asCurrentUser;
const result = await esClient.updateByQuery({
index,
body: {
script,
query,
},
});
return response.ok({ body: result });
} catch (e) {
console.error(e); // Log the error for debugging
return response.customError({ statusCode: 500, body: 'Internal Server Error' });
}
});
...