Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nicholas Westby 2024 posts 6952 karma points c-trib
    Jun 09, 2017 @ 20:45
    Nicholas Westby
    0

    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:

    Fix Button is Disabled

    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.";
    
    }
    

    How do I fix the "Fix" button?

  • Nicholas Westby 2024 posts 6952 karma points c-trib
    Jun 09, 2017 @ 21:05
    Nicholas Westby
    0

    I should have mentioned that these are the app settings in the web.config that this checks:

    <add key="robotnik-www.some-site.com" value="~/robots-primary.txt" />
    <add key="robotnik-localhost" value="~/robots-primary.txt" />
    <add key="robotnik-default" value="~/robots-disallow.txt" />
    

    Those exist under /configuration/appSettings.

  • Chriztian Steinmeier 2732 posts 8340 karma points MVP 5x admin c-trib
    Jun 10, 2017 @ 05:41
    Chriztian Steinmeier
    0

    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

  • Nicholas Westby 2024 posts 6952 karma points c-trib
    Jun 10, 2017 @ 06:26
    Nicholas Westby
    0

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

  • Micha Somers 134 posts 596 karma points
    Jun 10, 2017 @ 07:16
    Micha Somers
    0

    Hi Nicholas,

    Are you comparing the right value?

    Your code shows:

    new AcceptableConfiguration()
            {
                IsRecommended = false,
                Value = "robotnik-www.some-site.com"
            }
    

    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.

  • Nicholas Westby 2024 posts 6952 karma points c-trib
    Jun 10, 2017 @ 07:21
    Nicholas Westby
    0

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

  • Chriztian Steinmeier 2732 posts 8340 karma points MVP 5x admin c-trib
    Jun 10, 2017 @ 09:56
    Chriztian Steinmeier
    0

    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

  • Andy Butland 395 posts 2230 karma points MVP 4x hq c-trib
    Jun 10, 2017 @ 21:33
    Andy Butland
    102

    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.

  • Nicholas Westby 2024 posts 6952 karma points c-trib
    Jun 11, 2017 @ 01:26
    Nicholas Westby
    0

    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!

Please Sign in or register to post replies

Write your reply to:

Draft