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

Bug with health actuator showDetails #1411

Closed
TimHess opened this issue Dec 2, 2024 · 2 comments · Fixed by #1421
Closed

Bug with health actuator showDetails #1411

TimHess opened this issue Dec 2, 2024 · 2 comments · Fixed by #1421
Labels
Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line Type/bug Something isn't working
Milestone

Comments

@TimHess
Copy link
Member

TimHess commented Dec 2, 2024

Describe the bug

management:endpoints:health:showDetails does not affect whether details of the health check are included in the response.

Steps to reproduce

Steps to reproduce the behavior:

  1. Find test ...Endpoint.Test.Actuators.Health.EndpointMiddlewareTest.HealthActuator_ReturnsOnlyStatusWhenAuthorized
  2. Observe details in the health object during debugging

Expected behavior

The "details" property in the response should be empty when showDetails is Never or the user details in the request do not fit the configuration for WhenAuthorized

Additional detail

Steeltoe v4 code (HealthEndpointHandler.cs):

ShowDetails showDetails = endpointOptions.ShowDetails;
if (showDetails != ShowDetails.Never && (showDetails != ShowDetails.WhenAuthorized || healthRequest.HasClaim))
{
    foreach (string group in endpointOptions.Groups.Select(group => group.Key))
    {
        response.Groups.Add(group);
    }
}

Steeltoe v3 code:

var showDetails = Options.ShowDetails;
if (showDetails == ShowDetails.Never || (showDetails == ShowDetails.WhenAuthorized && !securityContext.HasClaim(Options.Claim)))
{
    response.Details = new Dictionary<string, object>();
}
else
{
    response.Groups = Options.Groups.Select(g => g.Key);
}
@TimHess TimHess added Type/bug Something isn't working Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line labels Dec 2, 2024
@TimHess TimHess added this to the 4.0.0-m1 milestone Dec 2, 2024
@TimHess
Copy link
Member Author

TimHess commented Dec 2, 2024

In my quick local test, showDetails works as expected when this is added after the snippet in HealthEndpointHandler

else
{
    response.Details.Clear();
}

@TimHess
Copy link
Member Author

TimHess commented Dec 2, 2024

Potentially related...

Given this response:

{
    "status": "UP",
    "details": {
        "diskSpace": {
            "status": "UP",
            "total": 1001462427648,
            "free": 256919261184,
            "threshold": 10485760
        },
        "readiness": {
            "status": "UP",
            "ReadinessState": "ACCEPTING_TRAFFIC"
        },
        "MySQL": {
            "status": "UP",
            "host": "localhost"
        },
        "liveness": {
            "status": "UP",
            "LivenessState": "CORRECT"
        }
    }
}

SBA shows this in the UI:
image

Compared with a Spring demo app:

{
    "status": "UP",
    "details": {
        "diskSpace": {
            "status": "UP",
            "details": {
                "total": 1001462427648,
                "free": 257143635968,
                "threshold": 10485760,
                "path": "C:\\Users\\timhe\\Downloads\\demo\\.",
                "exists": true
            }
        },
        "ping": {
            "status": "UP"
        }
    }
}

Which looks like this:
image

I don't know if any of this is relevant to #1367, but for both of these examples, the request included an Accept header with value application/vnd.spring-boot.actuator.v2+json,application/vnd.spring-boot.actuator.v1+json,application/json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line Type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant