Skip to content
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

Merged
merged 11 commits into from
Sep 17, 2019

Conversation

darnautov
Copy link
Contributor

@darnautov darnautov commented Sep 11, 2019

Summary

Extend job id validation messages specifying the max length restriction.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@walterra walterra left a 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 {
Copy link
Contributor

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.',
Copy link
Contributor

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.',
Copy link
Contributor

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?

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@peteharverson peteharverson added the Feature:Anomaly Detection ML anomaly detection label Sep 16, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@peteharverson peteharverson left a 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?

* Provides a validator function for maximum allowed input length.
* @param maxLength Maximum length allowed.
*/
export function maxLengthValidator(
Copy link
Member

@jgowdyelastic jgowdyelastic Sep 16, 2019

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.

Copy link
Member

@jgowdyelastic jgowdyelastic Sep 16, 2019

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.

Copy link
Contributor Author

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.

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 left a 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
Copy link
Contributor

@peteharverson peteharverson left a 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!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@peteharverson peteharverson left a 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;
Copy link
Contributor

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().

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@darnautov darnautov merged commit 87f81e8 into elastic:master Sep 17, 2019
@darnautov darnautov deleted the ML-job-id-error-message branch September 17, 2019 11:24
@darnautov darnautov self-assigned this Sep 17, 2019
darnautov added a commit to darnautov/kibana that referenced this pull request Sep 17, 2019
[ML] Enhance job id error message
rylnd added a commit to rylnd/kibana that referenced this pull request Sep 17, 2019
* 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)
  ...
darnautov added a commit that referenced this pull request Sep 18, 2019
* [ML] Enhance job id error message (#45349)

[ML] Enhance job id error message

* fix i18n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants