Page MenuHomePhabricator

Mentor dashboard: Error message for "away for too long" errors does not substitute params
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

image.png (1×3 px, 396 KB)

An error message appears saying Input in "You'll be gone for" is too high. The maximum number of days a mentor can be away for is $1 (one year).

What should have happened instead?:

The error message is displayed with proper parameter substitution, eg. saying:

Input in "You'll be gone for" is too high. The maximum number of days a mentor can be away for is 365 (one year).

Other information

Spotted when reviewing https://gerrit.wikimedia.org/r/c/mediawiki/extensions/GrowthExperiments/ /1091887, filling separately as it is irrelevant to the patch.

Event Timeline

Urbanecm_WMF triaged this task as Low priority.

Change #1092189 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/GrowthExperiments@master] AwaySettingsDialog: Do not parse error message on the client side

https://gerrit.wikimedia.org/r/1092189

Change #1092189 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] AwaySettingsDialog: Do not parse error message on the client side

https://gerrit.wikimedia.org/r/1092189

Checked in betalabs - the issue is fixed; entering a number >365 will produce the correct warning, i.e. $1 will show 365
@Urbanecm_WMF - please review my notes below to see if some follow-ups are needed

  • 366 is a valid number for a leap year, so if the warning message refers to one year, it, probably, should include a leap year too
  • entering big numbers, e.g. eight-digit numbers triggers invalid value timestamp parameter warning

{F57747387}

  • entering ten-digit numbers triggers Console error: Uncaught RangeError: invalid date. After that, the page needs to be reload, so the dialog will be able to accept the valid values.

{F57747408}

Change #1098497 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/GrowthExperiments@master] AwaySettingsDialog: Check range on the client side

https://gerrit.wikimedia.org/r/1098497

@Etonkovidova Thank you for the notes!

366 is a valid number for a leap year, so if the warning message refers to one year, it, probably, should include a leap year too

I'm not sure how to evaluate for that. If the user uses the form during a non-leap year, but they would be away during a leap year, should the limit be 365 or 366? I think it is more appropriate to count the limit's value in days, and set it as 365 days exactly. The difference should be negligible. I'd be happy to update the copy to not include the word "year" if someone thinks that would be a better thing to do.

entering big numbers, e.g. eight-digit numbers triggers invalid value timestamp parameter warning
entering ten-digit numbers triggers Console error: Uncaught RangeError: invalid date. After that, the page needs to be reload, so the dialog will be able to accept the valid values.

This is caused by datetime libraries not being able to work with dates too far in the future (let d = new Date(); d.setDate( 1000000000 ); d.toISOString(); throws that exception). This can be solved by doing the > 365 check client side (before the conversion to a timestamp). Besides fixing this bug, it also provides a quicker response (as it completely avoids the API call).

Moving back to Code Review.

Change #1098497 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] AwaySettingsDialog: Check range on the client side

https://gerrit.wikimedia.org/r/1098497

Thx, @Urbanecm_WMF - re 366 days a year - I agree it's negligible.

Two other points -entering big number of days triggering incorrect warnings - have been fixed.