-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Enhance job id error message #45349
Conversation
Pinging @elastic/ml-ui |
💚 Build Succeeded |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code overall looks good, I just added some questions. One more question I have: The naming JOB_ID_MAX_LENGTH = 64
somehow implies to me that 64
would be a valid max length, but then the checks are done using lesser than
and also the error messages say less than
. I couldn't find a reference how this is handled in the backend so can you double check if less than 64
is the correct validation?
actualLength: value.length, | ||
}, | ||
}; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolute nitpick: You could just skip the else
and return without it. For reference, here's the section on "return early from function" https://github.com/elastic/kibana/blob/master/style_guides/js_style_guide.md#returnthrow-early-from-functions
job_id_valid: { | ||
status: 'SUCCESS', | ||
heading: i18n.translate('xpack.ml.models.jobValidation.messages.jobIdValidHeading', { | ||
defaultMessage: 'Job id format is valid', | ||
}), | ||
text: i18n.translate('xpack.ml.models.jobValidation.messages.jobIdValidMessage', { | ||
defaultMessage: 'Lowercase alphanumeric (a-z and 0-9) characters, hyphens or underscores, ' + | ||
'starts and ends with an alphanumeric character.', | ||
'starts and ends with an alphanumeric character, and is less than 64 characters.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this also make use of JOB_ID_MAX_LENGTH
?
@@ -278,7 +288,7 @@ export const getMessages = () => { | |||
}), | |||
text: i18n.translate('xpack.ml.models.jobValidation.messages.jobGroupIdValidMessage', { | |||
defaultMessage: 'Lowercase alphanumeric (a-z and 0-9) characters, hyphens or underscores, ' + | |||
'starts and ends with an alphanumeric character.', | |||
'starts and ends with an alphanumeric character, and is less than 64 characters.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this also make use of JOB_ID_MAX_LENGTH
?
💚 Build Succeeded |
x-pack/legacy/plugins/ml/server/models/job_validation/messages.js
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/ml/server/models/job_validation/messages.js
Outdated
Show resolved
Hide resolved
💔 Build Failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions for slight rewording of the validation messages.
Checks works well for anomaly detection job IDs. Can we get the same check in for Analytics jobs too?
x-pack/legacy/plugins/ml/public/jobs/new_job_new/common/job_validator/util.ts
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/ml/public/jobs/new_job_new/common/job_validator/util.ts
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/ml/server/models/job_validation/messages.js
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/ml/server/models/job_validation/messages.js
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/ml/server/models/job_validation/messages.js
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/ml/server/models/job_validation/messages.js
Outdated
Show resolved
Hide resolved
* Provides a validator function for maximum allowed input length. | ||
* @param maxLength Maximum length allowed. | ||
*/ | ||
export function maxLengthValidator( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is now used as falsy check, the contents of the returned object are ignored.
Maybe it should be changed to just return a boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realised that there is a string_utils.js
file along side this file. IMO, this function is worth moving inside there, as it is validating the length of a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use it as falsy check because of the current code structure. Validator function provides useful info to render error messages as well as error key which lets generate an object with all errors for specific field/model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
💔 Build Failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.LGTM ⚡️
…essage # Conflicts: # x-pack/plugins/translations/translations/ja-JP.json # x-pack/plugins/translations/translations/zh-CN.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the new validations in the Anomaly Detection job wizards and the Analytics create job modal and works well. Just one typo needs fixing!
x-pack/legacy/plugins/ml/server/models/job_validation/messages.js
Outdated
Show resolved
Hide resolved
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest edits LGTM!
@@ -32,6 +32,7 @@ export interface State { | |||
jobId: DataFrameAnalyticsId; | |||
jobIdExists: boolean; | |||
jobIdEmpty: boolean; | |||
jobIdInvalidMaxLength?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to have this in line with the other attributes which are not optional. To fix it I think you just need to add a default jobIdInvalidMaxLength: false;
to getInitialState()
.
💚 Build Succeeded |
[ML] Enhance job id error message
* master: (33 commits) [easy] Exclude __examples__ from coverage (elastic#45556) [DOCS] Update CCR links (elastic#44012) Use unique junit report filenames again (elastic#45897) [ftr/savedObjects] add simple saved object api client to ftr s… (elastic#45856) New visualization editor Lens (elastic#36437) Sort using unix timestamp value (elastic#43162) [APM] Use POST instead of implicit GET (elastic#45903) [Canvas] Converting workpad header components to typescript and adding i18n (elastic#45274) skip flaky test (elastic#45884) set IS_PIPELINE_JOB in intake jobs (elastic#45850) [Uptime] Fix/issue 48 integration popup closes after refresh (elastic#45759) [Logs UI] Support zoom by brushing in the log rate chart (elastic#45879) [DOCS] Changes name to host (elastic#45798) [ML] Add population job wizard test (elastic#45765) [skip-ci][Maps][File upload] Geojson indexing and styling docs (elastic#41394) remove setTimeoue for state change (elastic#45853) [Graph] Restructure folders and add readme (elastic#45782) [ML] Enhance job id error message (elastic#45349) [SIEM] Do not update state component when they did unmount (elastic#45847) [i18n] sync from 7.4 latest translations (elastic#45823) ...
Summary
Extend job id validation messages specifying the max length restriction.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Documentation was added for features that require explanation or tutorialsThis was checked for keyboard-only and screenreader accessibilityFor maintainers
[ ] This was checked for breaking API changes and was labeled appropriately[ ] This includes a feature addition or change that requires a release note and was labeled appropriately