However, the "Fix" button is disabled and I can't figure out how to get it to be enabled:
Some relevant info:
There are no errors in the JavaScript console.
Umbraco 7.5.13.
Here's the code I'm using:
using System.Collections.Generic;
using Umbraco.Web.HealthCheck;
using Umbraco.Web.HealthCheck.Checks.Config;
[HealthCheck("B878A830-6DE4-4352-9283-4B867DCF7C75",
"Check Robotnik", Description = CheckDescription, Group = "Live Environment")]
public class RobotnikCheck : AbstractConfigCheck
{
private const string CheckDescription = "Checks the Robotnik configuration in the web.config to ensure you aren't still using the default sample domain.";
public RobotnikCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
{
}
public override string FilePath => "~/Web.config";
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldNotEqual;
public override IEnumerable<AcceptableConfiguration> Values => new[]
{
new AcceptableConfiguration()
{
IsRecommended = false,
Value = "robotnik-www.some-site.com"
}
};
public override string XPath => @"/configuration/appSettings/add[@value=""~/robots-primary.txt""][1]/@key";
public override string CheckSuccessMessage => "The sample Robotnik domain is no longer being used. That probably means you've replaced it with the correct domain.";
public override string CheckErrorMessage => @"The sample Robotnik domain is still being used. You should change it to the correct domain. For example, if you are working with www.microsoft.com, the value would be ""robotnik-www.microsoft.com"".";
public override string RectifySuccessMessage => "The Robotnik domain has been updated to the one you specified. Edit the web.config if you have more domains to add.";
}
I have no experience with custom HealthChecks but looking at the docs, don't you need to specify a Value with IsRecommended = true, for the engine to be able to "Fix"?
As I am reading it, it can't know which value is "correct"...
I'm afraid that does not apply in my situation. There are two ways to compare values: ShouldEqual and ShouldNotEqual. In the case of ShouldEqual, setting IsRecommended = true would make sense, as you know that value that should be recommended. In the case of ShouldNotEqual, setting IsRecommended = true does not make sense, as all of the values are the ones which should not be used.
In the case of ShouldEqual, the "Fix" button will automatically substitute the recommended value. In the case of ShouldNotHave, the user has to type in the value to replace (as shown on my screenshot).
I am comparing the correct value, yes. Note that the screenshot shows robotnik-www.site.com as the corrected value, not the value from the web.config. The "Fix" button in this case is supposed to replace the web.config value with the one I typed into the textbox.
As I have shown above, that value in the web.config is robotnik-www.some-site.com (the value it should not be, which is why the health check is giving me the opportunity to fix it... partially).
Actually, first thing that caught my eye was that the XPath expression is using double quotes instead of the usual single quotes in the predicate.
Now that shouldn't be a problem unless the logic inside Umbraco cheats and does some string concatenation on it...
(But that's just because I'm so used to XPath in XSLT where you'd always use single quotes since your expression is inside a double quoted XML attribute :-)
Pretty sure this is a bug. If you look here you can see the field where you enter the correct value in has a val-email attribute. Which is correct for the core health check for "Notification Email Settings", as that should be an email. But clearly validation for an email should only be for that check, not for all.
Expect it's not been noted before as I believe the "Notification Email Settings" check is the only one in core that allows you to provide a "fix" value.
I've created an issue for this on the tracker here.
Good eye! I was wondering how they were performing realtime validation. The email attribute makes perfect sense in retrospect. Thanks for also submitting the bug report!
Health Check "Fix" Button is Disabled?
I've been following these instructions to extend the Health Check dashboard: https://our.umbraco.org/documentation/Extending/Healthcheck/
However, the "Fix" button is disabled and I can't figure out how to get it to be enabled:
Some relevant info:
Here's the code I'm using:
How do I fix the "Fix" button?
I should have mentioned that these are the app settings in the web.config that this checks:
Those exist under
/configuration/appSettings
.Hi Nicholas,
I have no experience with custom HealthChecks but looking at the docs, don't you need to specify a Value with
IsRecommended = true
, for the engine to be able to "Fix"?As I am reading it, it can't know which value is "correct"...
/Chriztian
I'm afraid that does not apply in my situation. There are two ways to compare values: ShouldEqual and ShouldNotEqual. In the case of ShouldEqual, setting
IsRecommended = true
would make sense, as you know that value that should be recommended. In the case of ShouldNotEqual, settingIsRecommended = true
does not make sense, as all of the values are the ones which should not be used.In the case of ShouldEqual, the "Fix" button will automatically substitute the recommended value. In the case of ShouldNotHave, the user has to type in the value to replace (as shown on my screenshot).
Hi Nicholas,
Are you comparing the right value?
Your code shows:
With ValueComparisonType set to ShouldNotEqual, this would mean that your value:
robotnik-www.site.com
is not equal to the value:
robotnik-www.some-site.com
, so everything seems to be fine leaving the Fix button disabled.
I am comparing the correct value, yes. Note that the screenshot shows
robotnik-www.site.com
as the corrected value, not the value from the web.config. The "Fix" button in this case is supposed to replace the web.config value with the one I typed into the textbox.As I have shown above, that value in the web.config is
robotnik-www.some-site.com
(the value it should not be, which is why the health check is giving me the opportunity to fix it... partially).Actually, first thing that caught my eye was that the XPath expression is using double quotes instead of the usual single quotes in the predicate.
Now that shouldn't be a problem unless the logic inside Umbraco cheats and does some string concatenation on it...
(But that's just because I'm so used to XPath in XSLT where you'd always use single quotes since your expression is inside a double quoted XML attribute :-)
/Chriztian
Pretty sure this is a bug. If you look here you can see the field where you enter the correct value in has a
val-email
attribute. Which is correct for the core health check for "Notification Email Settings", as that should be an email. But clearly validation for an email should only be for that check, not for all.Expect it's not been noted before as I believe the "Notification Email Settings" check is the only one in core that allows you to provide a "fix" value.
I've created an issue for this on the tracker here.
Good eye! I was wondering how they were performing realtime validation. The email attribute makes perfect sense in retrospect. Thanks for also submitting the bug report!
is working on a reply...