diff --git a/x-pack/plugins/enterprise_search/server/lib/ml/ml_model_deployment_common.ts b/x-pack/plugins/enterprise_search/server/lib/ml/ml_model_deployment_common.ts index 59498b4d8587a..84af615841eaf 100644 --- a/x-pack/plugins/enterprise_search/server/lib/ml/ml_model_deployment_common.ts +++ b/x-pack/plugins/enterprise_search/server/lib/ml/ml_model_deployment_common.ts @@ -5,16 +5,12 @@ * 2.0. */ -import { ELASTIC_MODEL_DEFINITIONS } from '@kbn/ml-trained-models-utils'; - import { ElasticsearchResponseError, isNotFoundException, isResourceNotFoundException, } from '../../utils/identify_exceptions'; -export const acceptableModelNames = Object.keys(ELASTIC_MODEL_DEFINITIONS); - export function isNotFoundExceptionError(error: unknown): boolean { return ( isResourceNotFoundException(error as ElasticsearchResponseError) || @@ -23,20 +19,3 @@ export function isNotFoundExceptionError(error: unknown): boolean { error?.statusCode === 404 ); } - -export function throwIfNotAcceptableModelName(modelName: string) { - if (!acceptableModelNames.includes(modelName)) { - const notFoundError: ElasticsearchResponseError = { - meta: { - body: { - error: { - type: 'resource_not_found_exception', - }, - }, - statusCode: 404, - }, - name: 'ResponseError', - }; - throw notFoundError; - } -} diff --git a/x-pack/plugins/enterprise_search/server/lib/ml/start_ml_model_deployment.ts b/x-pack/plugins/enterprise_search/server/lib/ml/start_ml_model_deployment.ts index 75bac93c2d200..4f65dbf9ced64 100644 --- a/x-pack/plugins/enterprise_search/server/lib/ml/start_ml_model_deployment.ts +++ b/x-pack/plugins/enterprise_search/server/lib/ml/start_ml_model_deployment.ts @@ -12,10 +12,7 @@ import { MlTrainedModels } from '@kbn/ml-plugin/server'; import { MlModelDeploymentStatus, MlModelDeploymentState } from '../../../common/types/ml'; import { getMlModelDeploymentStatus } from './get_ml_model_deployment_status'; -import { - isNotFoundExceptionError, - throwIfNotAcceptableModelName, -} from './ml_model_deployment_common'; +import { isNotFoundExceptionError } from './ml_model_deployment_common'; export const startMlModelDeployment = async ( modelName: string, @@ -25,10 +22,6 @@ export const startMlModelDeployment = async ( throw new Error('Machine Learning is not enabled'); } - // before anything else, check our model name - // to ensure we only allow those names we want - throwIfNotAcceptableModelName(modelName); - try { // try and get the deployment status of the model first // and see if it's already deployed or deploying... diff --git a/x-pack/plugins/enterprise_search/server/lib/ml/start_ml_model_download.ts b/x-pack/plugins/enterprise_search/server/lib/ml/start_ml_model_download.ts index 4d7f3c21e1210..ffa51acc5bd32 100644 --- a/x-pack/plugins/enterprise_search/server/lib/ml/start_ml_model_download.ts +++ b/x-pack/plugins/enterprise_search/server/lib/ml/start_ml_model_download.ts @@ -11,10 +11,7 @@ import { MlTrainedModels } from '@kbn/ml-plugin/server'; import { MlModelDeploymentState, MlModelDeploymentStatus } from '../../../common/types/ml'; import { getMlModelDeploymentStatus } from './get_ml_model_deployment_status'; -import { - isNotFoundExceptionError, - throwIfNotAcceptableModelName, -} from './ml_model_deployment_common'; +import { isNotFoundExceptionError } from './ml_model_deployment_common'; export const startMlModelDownload = async ( modelName: string, @@ -24,10 +21,6 @@ export const startMlModelDownload = async ( throw new Error('Machine Learning is not enabled'); } - // before anything else, check our model name - // to ensure we only allow those names we want - throwIfNotAcceptableModelName(modelName); - try { // try and get the deployment status of the model first // and see if it's already deployed or deploying...