Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Sep 11, 2023
1 parent 2689ee6 commit 8c7e6ce
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion x-pack/plugins/task_manager/server/task_validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -65,6 +65,12 @@ export class TaskValidator {
const latestStateSchema = this.cachedGetLatestStateSchema(taskTypeDef);

let state = task.state;

// Skip validating tasks who don't use state
if (!latestStateSchema && isEmpty(state)) {
return task;
}

try {
state = this.getValidatedStateSchema(
this.migrateTaskState(task.state, task.stateVersion, taskTypeDef, latestStateSchema),
Expand Down Expand Up @@ -104,6 +110,11 @@ export class TaskValidator {
const taskTypeDef = this.definitions.get(task.taskType);
const latestStateSchema = this.cachedGetLatestStateSchema(taskTypeDef);

// Skip validating tasks who don't use state
if (!latestStateSchema && isEmpty(task.state)) {
return task;
}

// We are doing a write operation which must validate against the latest state schema
return {
...task,
Expand Down

0 comments on commit 8c7e6ce

Please sign in to comment.