Skip to content

Commit

Permalink
convert modelMemoryLimit nums to strings before validation check (#54011
Browse files Browse the repository at this point in the history
)
  • Loading branch information
alvarezmelissa87 authored Jan 7, 2020
1 parent fef8485 commit 9aa2341
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/ml/common/util/job_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ export function validateModelMemoryLimitUnits(modelMemoryLimit) {
let valid = true;

if (modelMemoryLimit !== undefined) {
const mml = modelMemoryLimit.toUpperCase();
const mml = String(modelMemoryLimit).toUpperCase();
const mmlSplit = mml.match(/\d+(\w+)$/);
const unit = mmlSplit && mmlSplit.length === 2 ? mmlSplit[1] : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,11 @@ describe('useCreateAnalyticsForm', () => {
validateAdvancedEditor(getMockState({ index: 'the-source-index', modelMemoryLimit: '' }))
.isValid
).toBe(false);
// can still run validation check on model_memory_limit if number type
expect(
// @ts-ignore number is not assignable to type string - mml gets converted to string prior to creation
validateAdvancedEditor(getMockState({ index: 'the-source-index', modelMemoryLimit: 100 }))
.isValid
).toBe(false);
});
});

0 comments on commit 9aa2341

Please sign in to comment.