diff --git a/src/core/server/plugins/plugins_service.ts b/src/core/server/plugins/plugins_service.ts index a937bf5ff2c2c..9def7554ccd09 100644 --- a/src/core/server/plugins/plugins_service.ts +++ b/src/core/server/plugins/plugins_service.ts @@ -314,39 +314,7 @@ export class PluginsService implements CoreService + ) { + const { name, manifest, requiredBundles, requiredPlugins } = plugin; + + // validate that `requiredBundles` ids point to a discovered plugin which `includesUiPlugin` + for (const requiredBundleId of requiredBundles) { + if (!pluginEnableStatuses.has(requiredBundleId)) { + throw new Error( + `Plugin bundle with id "${requiredBundleId}" is required by plugin "${name}" but it is missing.` + ); + } + + const requiredPlugin = pluginEnableStatuses.get(requiredBundleId)!.plugin; + if (!requiredPlugin.includesUiPlugin) { + throw new Error( + `Plugin bundle with id "${requiredBundleId}" is required by plugin "${name}" but it doesn't have a UI bundle.` + ); + } + + if (requiredPlugin.manifest.type !== plugin.manifest.type) { + throw new Error( + `Plugin bundle with id "${requiredBundleId}" is required by plugin "${name}" and expected to have "${manifest.type}" type, but its type is "${requiredPlugin.manifest.type}".` + ); + } + } + + // validate that OSS plugins do not have required dependencies on X-Pack plugins + if (plugin.source === 'oss') { + for (const id of [...requiredPlugins, ...requiredBundles]) { + const requiredPlugin = pluginEnableStatuses.get(id); + if (requiredPlugin && requiredPlugin.plugin.source === 'x-pack') { + throw new Error( + `X-Pack plugin or bundle with id "${id}" is required by OSS plugin "${name}", which is prohibited. Consider making this an optional dependency instead.` + ); + } + } + } + } + private shouldEnablePlugin( pluginName: PluginName, pluginEnableStatuses: Map,