[ML] Enhance job id error message#45349
Conversation
|
Pinging @elastic/ml-ui |
💚 Build Succeeded |
💚 Build Succeeded |
walterra
left a comment
There was a problem hiding this comment.
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.
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
| 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.
Could this also make use of JOB_ID_MAX_LENGTH?
| 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.
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 |
peteharverson
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
💔 Build Failed |
…essage # Conflicts: # x-pack/plugins/translations/translations/ja-JP.json # x-pack/plugins/translations/translations/zh-CN.json
peteharverson
left a comment
There was a problem hiding this comment.
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 |
peteharverson
left a comment
There was a problem hiding this comment.
Latest edits LGTM!
| jobId: DataFrameAnalyticsId; | ||
| jobIdExists: boolean; | ||
| jobIdEmpty: boolean; | ||
| jobIdInvalidMaxLength?: boolean; |
There was a problem hiding this comment.
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