From 6cf246b50503928abe03e07b69cd82c43ba84609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Efe=20G=C3=BCrkan=20YALAMAN?= Date: Tue, 26 Sep 2023 18:22:00 +0200 Subject: [PATCH 1/7] Gracefully handle 404s for documents and mappings (#167101) ## Summary ![Screenshot 2023-09-25 at 17 09 34](https://github.com/elastic/kibana/assets/1410658/eb040d9c-6521-4a05-a57f-3e9d15b2db0a) ![Screenshot 2023-09-25 at 17 09 42](https://github.com/elastic/kibana/assets/1410658/cbc41a65-697b-4011-968b-fb6660835d28) ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com> --- .../components/search_index/documents.tsx | 27 +++++++++++++++-- .../search_index/index_mappings.tsx | 30 ++++++++++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/documents.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/documents.tsx index 694639b1d19c6..b2932c9547e27 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/documents.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/documents.tsx @@ -10,6 +10,7 @@ import React, { useEffect, useState, ChangeEvent } from 'react'; import { useActions, useValues } from 'kea'; import { + EuiCallOut, EuiFieldSearch, EuiFlexGroup, EuiFlexItem, @@ -74,7 +75,7 @@ export const SearchIndexDocuments: React.FC = () => { const { makeRequest: getDocuments } = useActions(documentLogic); const { makeRequest: getMappings } = useActions(mappingLogic); - const { data, status } = useValues(documentLogic); + const { data, status, error } = useValues(documentLogic); const { data: mappingData, status: mappingStatus } = useValues(mappingLogic); const docs = data?.results?.hits.hits ?? []; @@ -84,6 +85,8 @@ export const SearchIndexDocuments: React.FC = () => { const shouldShowAccessControlSwitcher = hasDocumentLevelSecurityFeature && productFeatures.hasDocumentLevelSecurityEnabled; + const isAccessControlIndexNotFound = + shouldShowAccessControlSwitcher && error?.body?.statusCode === 404; useEffect(() => { getDocuments({ @@ -141,11 +144,29 @@ export const SearchIndexDocuments: React.FC = () => { - {docs.length === 0 && + {isAccessControlIndexNotFound && ( + +

+ {i18n.translate('xpack.enterpriseSearch.content.searchIndex.documents.noIndex', { + defaultMessage: + "An Access Control Index won't be created until you enable document-level security and run your first access control sync.", + })} +

+
+ )} + {!isAccessControlIndexNotFound && + docs.length === 0 && i18n.translate('xpack.enterpriseSearch.content.searchIndex.documents.noMappings', { defaultMessage: 'No documents found for index', })} - {docs.length > 0 && ( + {!isAccessControlIndexNotFound && docs.length > 0 && ( { ? indexName : stripSearchPrefix(indexName, CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX); const { makeRequest: makeMappingRequest } = useActions(mappingsWithPropsApiLogic(indexToShow)); - const { data: mappingData } = useValues(mappingsWithPropsApiLogic(indexToShow)); + const { data: mappingData, error } = useValues(mappingsWithPropsApiLogic(indexToShow)); const shouldShowAccessControlSwitch = hasDocumentLevelSecurityFeature && productFeatures.hasDocumentLevelSecurityEnabled; + const isAccessControlIndexNotFound = + shouldShowAccessControlSwitch && error?.body?.statusCode === 404; + useEffect(() => { makeMappingRequest({ indexName: indexToShow }); }, [indexToShow, indexName]); @@ -77,9 +81,27 @@ export const SearchIndexIndexMappings: React.FC = () => {
)} - - {JSON.stringify(mappingData, null, 2)} - + {isAccessControlIndexNotFound ? ( + +

+ {i18n.translate('xpack.enterpriseSearch.content.searchIndex.mappings.noIndex', { + defaultMessage: + "An Access Control Index won't be created until you enable document-level security and run your first access control sync.", + })} +

+
+ ) : ( + + {JSON.stringify(mappingData, null, 2)} + + )}
From 302ec109ceb0416d124874a88dd83a8243ee083c Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Tue, 26 Sep 2023 17:25:25 +0100 Subject: [PATCH 2/7] [ML] Adding created_by job property for the advanced wizard (#167021) Adds `created_by` property of `advanced-wizard` to all jobs created by the advanced job wizard. Previously no `created_by` property was added to these jobs. When cloning, jobs with no `created_by` property or one with a value of `advanced-wizard` will be opened in the advanced wizard. Closes https://github.com/elastic/kibana/issues/166053 --- x-pack/plugins/ml/common/constants/new_job.ts | 1 + .../public/application/jobs/jobs_list/components/utils.js | 8 +++++++- .../new_job/common/job_creator/advanced_job_creator.ts | 6 ++++-- .../jobs/new_job/common/job_creator/geo_job_creator.ts | 6 +++++- .../common/job_creator/multi_metric_job_creator.ts | 6 +++++- .../new_job/common/job_creator/population_job_creator.ts | 6 +++++- .../jobs/new_job/common/job_creator/rare_job_creator.ts | 6 +++++- .../common/job_creator/single_metric_job_creator.ts | 2 +- .../pages/index_or_search/preconfigured_job_redirect.ts | 1 + 9 files changed, 34 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/ml/common/constants/new_job.ts b/x-pack/plugins/ml/common/constants/new_job.ts index 12aa5393ad6e1..24584a6e8d29b 100644 --- a/x-pack/plugins/ml/common/constants/new_job.ts +++ b/x-pack/plugins/ml/common/constants/new_job.ts @@ -19,6 +19,7 @@ export enum CREATED_BY_LABEL { SINGLE_METRIC = 'single-metric-wizard', MULTI_METRIC = 'multi-metric-wizard', POPULATION = 'population-wizard', + ADVANCED = 'advanced-wizard', CATEGORIZATION = 'categorization-wizard', RARE = 'rare-wizard', GEO = 'geo-wizard', diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js index ea8a43b51c47d..9dfef0ff8b5a3 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js @@ -24,6 +24,7 @@ import { mlCalendarService } from '../../../services/calendar_service'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { ML_PAGES } from '../../../../../common/constants/locator'; import { PLUGIN_ID } from '../../../../../common/constants/app'; +import { CREATED_BY_LABEL } from '../../../../../common/constants/new_job'; export function loadFullJob(jobId) { return new Promise((resolve, reject) => { @@ -240,7 +241,12 @@ export async function cloneJob(jobId) { return; } - if (cloneableJob !== undefined && originalJob?.custom_settings?.created_by !== undefined) { + const createdBy = originalJob?.custom_settings?.created_by; + if ( + cloneableJob !== undefined && + createdBy !== undefined && + createdBy !== CREATED_BY_LABEL.ADVANCED + ) { // if the job is from a wizards, i.e. contains a created_by property // use tempJobCloningObjects to temporarily store the job mlJobService.tempJobCloningObjects.createdBy = originalJob?.custom_settings?.created_by; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts index face450f58cd3..150b57402ee5e 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts @@ -11,14 +11,14 @@ import type { Field, Aggregation, SplitField } from '@kbn/ml-anomaly-utils'; import type { SavedSearch } from '@kbn/saved-search-plugin/public'; import { JobCreator } from './job_creator'; -import { +import type { Job, Datafeed, Detector, CustomRule, } from '../../../../../../common/types/anomaly_detection_jobs'; import { createBasicDetector } from './util/default_configs'; -import { JOB_TYPE } from '../../../../../../common/constants/new_job'; +import { CREATED_BY_LABEL, JOB_TYPE } from '../../../../../../common/constants/new_job'; import { getRichDetectors } from './util/general'; import { isValidJson } from '../../../../../../common/util/validation_utils'; @@ -41,6 +41,7 @@ export class AdvancedJobCreator extends JobCreator { constructor(indexPattern: DataView, savedSearch: SavedSearch | null, query: object) { super(indexPattern, savedSearch, query); + this.createdBy = CREATED_BY_LABEL.ADVANCED; this._queryString = JSON.stringify(this._datafeed_config.query); @@ -182,6 +183,7 @@ export class AdvancedJobCreator extends JobCreator { public cloneFromExistingJob(job: Job, datafeed: Datafeed) { this._overrideConfigs(job, datafeed); + this.createdBy = CREATED_BY_LABEL.ADVANCED; const detectors = getRichDetectors(job, datafeed, this.additionalFields, true); // keep track of the custom rules for each detector diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/geo_job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/geo_job_creator.ts index 596eb56230dc0..59e89070b38dd 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/geo_job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/geo_job_creator.ts @@ -9,7 +9,11 @@ import type { DataView } from '@kbn/data-views-plugin/public'; import type { Field, Aggregation, SplitField, AggFieldPair } from '@kbn/ml-anomaly-utils'; import type { SavedSearch } from '@kbn/saved-search-plugin/public'; import { JobCreator } from './job_creator'; -import { Job, Datafeed, Detector } from '../../../../../../common/types/anomaly_detection_jobs'; +import type { + Job, + Datafeed, + Detector, +} from '../../../../../../common/types/anomaly_detection_jobs'; import { createBasicDetector } from './util/default_configs'; import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job'; import { getRichDetectors } from './util/general'; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/multi_metric_job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/multi_metric_job_creator.ts index 794057ea209e8..39ad966b595e7 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/multi_metric_job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/multi_metric_job_creator.ts @@ -9,7 +9,11 @@ import type { DataView } from '@kbn/data-views-plugin/public'; import type { Field, Aggregation, SplitField, AggFieldPair } from '@kbn/ml-anomaly-utils'; import type { SavedSearch } from '@kbn/saved-search-plugin/public'; import { JobCreator } from './job_creator'; -import { Job, Datafeed, Detector } from '../../../../../../common/types/anomaly_detection_jobs'; +import type { + Job, + Datafeed, + Detector, +} from '../../../../../../common/types/anomaly_detection_jobs'; import { createBasicDetector } from './util/default_configs'; import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job'; import { getRichDetectors } from './util/general'; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/population_job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/population_job_creator.ts index 09f10b0a2f1aa..08de5d30d11eb 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/population_job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/population_job_creator.ts @@ -9,7 +9,11 @@ import type { DataView } from '@kbn/data-views-plugin/public'; import type { Field, Aggregation, SplitField, AggFieldPair } from '@kbn/ml-anomaly-utils'; import type { SavedSearch } from '@kbn/saved-search-plugin/public'; import { JobCreator } from './job_creator'; -import { Job, Datafeed, Detector } from '../../../../../../common/types/anomaly_detection_jobs'; +import type { + Job, + Datafeed, + Detector, +} from '../../../../../../common/types/anomaly_detection_jobs'; import { createBasicDetector } from './util/default_configs'; import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job'; import { getRichDetectors } from './util/general'; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/rare_job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/rare_job_creator.ts index f586ec332773d..cc9601fc85634 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/rare_job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/rare_job_creator.ts @@ -14,7 +14,11 @@ import { } from '@kbn/ml-anomaly-utils'; import type { SavedSearch } from '@kbn/saved-search-plugin/public'; import { JobCreator } from './job_creator'; -import { Job, Datafeed, Detector } from '../../../../../../common/types/anomaly_detection_jobs'; +import type { + Job, + Datafeed, + Detector, +} from '../../../../../../common/types/anomaly_detection_jobs'; import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job'; import { getRichDetectors, isSparseDataJob } from './util/general'; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/single_metric_job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/single_metric_job_creator.ts index b0a1a1136bc6b..07a949b6a34a3 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/single_metric_job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/single_metric_job_creator.ts @@ -17,7 +17,7 @@ import { import type { SavedSearch } from '@kbn/saved-search-plugin/public'; import { parseInterval } from '../../../../../../common/util/parse_interval'; import { JobCreator } from './job_creator'; -import { +import type { Job, Datafeed, Detector, diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/index_or_search/preconfigured_job_redirect.ts b/x-pack/plugins/ml/public/application/jobs/new_job/pages/index_or_search/preconfigured_job_redirect.ts index 471ba1e30608e..3f288d8f6191f 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/index_or_search/preconfigured_job_redirect.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/index_or_search/preconfigured_job_redirect.ts @@ -63,6 +63,7 @@ async function getWizardUrlFromCloningJob(createdBy: string | undefined, dataVie case CREATED_BY_LABEL.GEO: page = JOB_TYPE.GEO; break; + case CREATED_BY_LABEL.ADVANCED: default: page = JOB_TYPE.ADVANCED; break; From 090569bb45573cc5df92add8c1a114134e8079e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yulia=20=C4=8Cech?= <6585477+yuliacech@users.noreply.github.com> Date: Tue, 26 Sep 2023 18:36:46 +0200 Subject: [PATCH 3/7] [Management team] Fix the type check errors (#167133) ## Summary This PR fixes the errors of the type checkers on some of the Management team's plugins. The errors were identified by running the command `node scripts/type_check --project ` with these files as suggested by the Operations team: - ./packages/kbn-generate-console-definitions/tsconfig.json - ./src/plugins/console/tsconfig.json - ./packages/kbn-management/settings/components/field_row/tsconfig.json --- .../components/field_row/footer/change_image_link.test.tsx | 2 +- .../settings/components/field_row/footer/index.ts | 3 ++- src/plugins/console/public/lib/autocomplete/autocomplete.ts | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/kbn-management/settings/components/field_row/footer/change_image_link.test.tsx b/packages/kbn-management/settings/components/field_row/footer/change_image_link.test.tsx index 201942bc89d44..c101ef175b395 100644 --- a/packages/kbn-management/settings/components/field_row/footer/change_image_link.test.tsx +++ b/packages/kbn-management/settings/components/field_row/footer/change_image_link.test.tsx @@ -16,7 +16,7 @@ const IMAGE = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8 describe('ChangeImageLink', () => { const defaultProps: ChangeImageLinkProps = { field: { - name: 'test', + id: 'test', type: 'image', ariaAttributes: { ariaLabel: 'test', diff --git a/packages/kbn-management/settings/components/field_row/footer/index.ts b/packages/kbn-management/settings/components/field_row/footer/index.ts index 0322c72010380..fc8cac296885c 100644 --- a/packages/kbn-management/settings/components/field_row/footer/index.ts +++ b/packages/kbn-management/settings/components/field_row/footer/index.ts @@ -7,4 +7,5 @@ */ export { FieldInputFooter, type FieldInputFooterProps } from './input_footer'; -export { InputResetLink, type FieldResetLinkProps } from './reset_link'; +export { InputResetLink } from './reset_link'; +export type { InputResetLinkProps } from './reset_link'; diff --git a/src/plugins/console/public/lib/autocomplete/autocomplete.ts b/src/plugins/console/public/lib/autocomplete/autocomplete.ts index 487ed95672d83..d6bb3879669ae 100644 --- a/src/plugins/console/public/lib/autocomplete/autocomplete.ts +++ b/src/plugins/console/public/lib/autocomplete/autocomplete.ts @@ -998,12 +998,12 @@ export default function ({ ) { // will simulate autocomplete on 'GET /a/b/' with a filter by index return { - tokenPath: context.urlTokenPath.slice(0, -1), - predicate: (term) => term.meta === 'index', + tokenPath: context.urlTokenPath?.slice(0, -1), + predicate: (term: any) => term.meta === 'index', }; } else { // will do nothing special - return { tokenPath: context.urlTokenPath, predicate: (term) => true }; + return { tokenPath: context.urlTokenPath, predicate: () => true }; } })(); From 9cccd0ee4d9e88d8114ccceb463f92b5bd07eca9 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Tue, 26 Sep 2023 20:27:57 +0200 Subject: [PATCH 4/7] Upgrade execa from v4.1.0 to v5.1.1 (#167211) --- package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a08963d37feea..90d9f8aa5d2d7 100644 --- a/package.json +++ b/package.json @@ -880,7 +880,7 @@ "del": "^6.1.0", "elastic-apm-node": "^4.0.0", "email-addresses": "^5.0.0", - "execa": "^4.0.2", + "execa": "^5.1.1", "expiry-js": "0.1.7", "extract-zip": "^2.0.1", "fast-deep-equal": "^3.1.1", diff --git a/yarn.lock b/yarn.lock index 7e1992e29ade1..6a4f80236417c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16172,7 +16172,7 @@ exec-sh@^0.3.2: resolved "https://registry.yarnpkg.com/exec-sh/-/exec-sh-0.3.2.tgz#6738de2eb7c8e671d0366aea0b0db8c6f7d7391b" integrity sha512-9sLAvzhI5nc8TpuQUh4ahMdCrWT00wPWz7j47/emR5+2qEfoZP5zzUXvx+vdx+H6ohhnsYC31iX04QLYJK8zTg== -execa@4.1.0, execa@^4.0.2: +execa@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a" integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA== From d86eebd6c1e7dd8b084bba91566fdd9298293b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20C=C3=B4t=C3=A9?= Date: Tue, 26 Sep 2023 14:29:38 -0400 Subject: [PATCH 5/7] [Task Manager] Force validation on all tasks using state (#164574) Resolves https://github.com/elastic/kibana/issues/159347 Part of https://github.com/elastic/kibana/issues/155764 In this PR, I'm forcing validation on any tasks using state by ensuring a state schema is defined by the task type. Without this schema and once this PR merges, Task Manager will now fail validation by throwing `[TaskValidator] stateSchemaByVersion not defined for task type: XYZ` errors. This forces an explicit schema to be defined so we can properly handle state objects in ZDT environments. --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../task_manager/server/task_validator.test.ts | 8 ++------ .../task_manager/server/task_validator.ts | 17 +++++++---------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/task_manager/server/task_validator.test.ts b/x-pack/plugins/task_manager/server/task_validator.test.ts index 52822adf6f49f..08c18591e468e 100644 --- a/x-pack/plugins/task_manager/server/task_validator.test.ts +++ b/x-pack/plugins/task_manager/server/task_validator.test.ts @@ -64,9 +64,7 @@ describe('TaskValidator', () => { expect(result).toEqual(task); }); - // TODO: Remove skip once all task types have defined their state schema. - // https://github.com/elastic/kibana/issues/159347 - it.skip(`should fail to validate the state schema when the task type doesn't have stateSchemaByVersion defined`, () => { + it(`should fail to validate the state schema when the task type doesn't have stateSchemaByVersion defined`, () => { const definitions = new TaskTypeDictionary(mockLogger()); definitions.registerTaskDefinitions({ foo: fooTaskDefinition, @@ -322,9 +320,7 @@ describe('TaskValidator', () => { expect(result).toEqual(task); }); - // TODO: Remove skip once all task types have defined their state schema. - // https://github.com/elastic/kibana/issues/159347 - it.skip(`should fail to validate the state schema when the task type doesn't have stateSchemaByVersion defined`, () => { + it(`should fail to validate the state schema when the task type doesn't have stateSchemaByVersion defined`, () => { const definitions = new TaskTypeDictionary(mockLogger()); definitions.registerTaskDefinitions({ foo: fooTaskDefinition, diff --git a/x-pack/plugins/task_manager/server/task_validator.ts b/x-pack/plugins/task_manager/server/task_validator.ts index 61d9a903dd5b4..900af04cd1207 100644 --- a/x-pack/plugins/task_manager/server/task_validator.ts +++ b/x-pack/plugins/task_manager/server/task_validator.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { max, memoize } from 'lodash'; +import { max, memoize, isEmpty } from 'lodash'; import type { Logger } from '@kbn/core/server'; import type { ObjectType } from '@kbn/config-schema'; import { TaskTypeDictionary } from './task_type_dictionary'; @@ -64,14 +64,13 @@ export class TaskValidator { const taskTypeDef = this.definitions.get(task.taskType); const latestStateSchema = this.cachedGetLatestStateSchema(taskTypeDef); - // TODO: Remove once all task types have defined their state schema. - // https://github.com/elastic/kibana/issues/159347 - // Otherwise, failures on read / write would occur. (don't forget to unskip test) - if (!latestStateSchema) { + let state = task.state; + + // Skip validating tasks that don't use state + if (!latestStateSchema && isEmpty(state)) { return task; } - let state = task.state; try { state = this.getValidatedStateSchema( this.migrateTaskState(task.state, task.stateVersion, taskTypeDef, latestStateSchema), @@ -111,10 +110,8 @@ export class TaskValidator { const taskTypeDef = this.definitions.get(task.taskType); const latestStateSchema = this.cachedGetLatestStateSchema(taskTypeDef); - // TODO: Remove once all task types have defined their state schema. - // https://github.com/elastic/kibana/issues/159347 - // Otherwise, failures on read / write would occur. (don't forget to unskip test) - if (!latestStateSchema) { + // Skip validating tasks that don't use state + if (!latestStateSchema && isEmpty(task.state)) { return task; } From 838500336cafb8acc74845c4cce5bdb49621e10a Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Tue, 26 Sep 2023 20:32:36 +0200 Subject: [PATCH 6/7] [Ops] Add ability to scope type check to staged files (#167236) --- .../scripts/steps/check_types_commits.sh | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.buildkite/scripts/steps/check_types_commits.sh b/.buildkite/scripts/steps/check_types_commits.sh index 113f516efc023..36ea6299194e9 100755 --- a/.buildkite/scripts/steps/check_types_commits.sh +++ b/.buildkite/scripts/steps/check_types_commits.sh @@ -9,18 +9,28 @@ if [[ "${CI-}" == "true" ]]; then sha1=$(git merge-base $GITHUB_PR_TARGET_BRANCH $GITHUB_PR_TRIGGERED_SHA) sha2="${GITHUB_PR_TRIGGERED_SHA-}" else - # Script take between 0 and 2 arguments representing two commit SHA's: - # If 0, it will diff HEAD and HEAD^ - # If 1 (SHA1), it will diff SHA1 and SHA1^ - # If 2 (SHA1, SHA2), it will diff SHA1 and SHA2 - sha1="${1-HEAD}" - sha2="${2-$sha1^}" + if [[ "${1-}" == "--cached" ]]; then + # Only check staged files + sha1=$1 + sha2="" + else + # Script take between 0 and 2 arguments representing two commit SHA's: + # If 0, it will diff HEAD and HEAD^ + # If 1 (SHA1), it will diff SHA1 and SHA1^ + # If 2 (SHA1, SHA2), it will diff SHA1 and SHA2 + sha1="${1-HEAD}" + sha2="${2-$sha1^}" + fi fi uniq_dirs=() uniq_tsconfigs=() -echo "Detecting files changed between $sha1 and $sha2..." +if [[ "$sha1" == "--cached" ]]; then + echo "Detecting files changed in staging area..." +else + echo "Detecting files changed between $sha1 and $sha2..." +fi files=($(git diff --name-only $sha1 $sha2)) @@ -102,7 +112,11 @@ do done if [ ${#uniq_tsconfigs[@]} -eq 0 ]; then - echo "No tsconfig.json files found for changes in $sha1 $sha2" + if [[ "$sha1" == "--cached" ]]; then + echo "No tsconfig.json files found for staged changes" + else + echo "No tsconfig.json files found for changes between $sha1 and $sha2" + fi exit fi From f42b40fe35ffe1384d6ef146a2b8c1c1556770d1 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Tue, 26 Sep 2023 20:33:06 +0200 Subject: [PATCH 7/7] [type check] Fix ./test/tsconfig.json TypeScript errors (#167239) Co-authored-by: Stratoula Kalafateli --- test/functional/apps/console/_autocomplete.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/functional/apps/console/_autocomplete.ts b/test/functional/apps/console/_autocomplete.ts index dd2e5a131efea..2f9d8db9cf9d2 100644 --- a/test/functional/apps/console/_autocomplete.ts +++ b/test/functional/apps/console/_autocomplete.ts @@ -213,11 +213,10 @@ GET _search 'pressRight', 'pressLeft', 'pressLeft', - ]; + ] as const; for (const keyPress of keyPresses) { await PageObjects.console.sleepForDebouncePeriod(); log.debug('Key', keyPress); - // @ts-ignore await PageObjects.console[keyPress](); expect(await PageObjects.console.isAutocompleteVisible()).to.be.eql(false); } @@ -258,7 +257,7 @@ GET _search for (const char of [method.at(-1), ' ', '_']) { await PageObjects.console.sleepForDebouncePeriod(); log.debug('Key type "%s"', char); - await PageObjects.console.enterText(char ?? ''); // e.g. 'Post ' -> 'Post _' + await PageObjects.console.enterText(char!); // e.g. 'Post ' -> 'Post _' } await retry.waitFor('autocomplete to be visible', () =>