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

Problem updating a strategy parameter when it contains a comma using actuator with TogglzEndpoint #1109

Open
rocastaneda opened this issue Aug 22, 2023 · 2 comments

Comments

@rocastaneda
Copy link

when trying to update a parameter of the strategy (IP Address Server) that contains a list separated by commas, it does not allow its update since the implementation for separating the parameters uses the comma character as delimiter.

TogglzEndpoint.java

image

In the implementation, it does not allow changing the delimiter for the separation of the parameters, always leaving the comma character as fixed.

image

If we view it from the console, it can be edited and consulted if there is a problem.

image

But when you want to update via a POST request using "actuator/togglz" a Bad Request error is generated.

Get Feature.

{
        "name": "my_strategy",
        "enabled": true,
        "strategy": "server-ip",
        "params": {
            "ips": "10.0.0.2,10.3.1.0"
        },
        "metadata": {
            "label": "Server IPs",
            "groups": [
                "IPs"
            ],
            "enabledByDefault": true,
            "attributes": {}
        }
    }

But when the POST call to the "/actuator/togglz" resource is generated, the Bad Request error is generated.

{
    "name": "my_strategy",
    "strategy": "server-ip",
    "parameters": "ips=10.0.0.3,10.3.1.5"
}

image

Could you tell me if this is really a bug or if there is any way to be able to carry out this update using the "actuator/togglz" resource?

@bennetelli
Copy link
Member

bennetelli commented Oct 25, 2023

Hey @rocastaneda

When I add an IP via console and use curl then:

curl -d '{"name":"REVERSE_GREETING", "enabled":"true", "strategy": "server-ip"}' -H "Content-Type: application/json" -POST http://localhost:8082/actuator/togglz/REVERSE_GREETING
{"name":"REVERSE_GREETING","enabled":true,"strategy":"server-ip","params":{"ips":"192.168.178.1"},"metadata":{"label":"another description","groups":["eins"],"enabledByDefault":false,"attributes":{}}}%

then I am getting the expected response containing the IP.

But when I then try to Post the same IP again:

curl -d '{"name":"REVERSE_GREETING","enabled":false,"strategy":"server-ip","params":{"ips":"192.168.178.1"}' -H "Content-Type: application/json" -POST http://localhost:8082/actuator/togglz/REVERSE_GREETING

Then I am also getting a HTTP 400 Bad Request.
I tried to disable Spring Security stuff completely, but this did not have an effect on it.

In general this should work. There is also a Test for it and it is also working in console. So I would say this is something I should do on my togglz-site so everyone can use it the way you want it to use.

There are some tests out there containing your case already, but not an integration test including the actuator stuff. I remember that the actuator stuff is a bit "bitchy" .. Will dive into it.

Thanks for raising this issue :-)

I hope you are still able to work with togglz even when this issue is there?

@bennetelli
Copy link
Member

bennetelli commented Oct 27, 2023

I just created a custom actuator endpoint and am testing it with some curl requests:

curl -d '{ version: "1.0" }' -H "Content-Type: application/json" -X POST http://localhost:8080/actuator/custom

This one leads to a HTTP Bad Request response. There is no hint that the json object is invalid. It just responds with Bad Request.

While this one leads to an "OK" (json is valid):
curl -d '{ "version": "1.0" }' -H "Content-Type: application/json" -X POST http://localhost:8080/actuator/custom

and also this one containing a comma separated value leads to an "OK":
curl -d '{ "version": "1.0, 2.1337" }' -H "Content-Type: application/json" -X POST http://localhost:8080/actuator/custom

Not sure why it's painting that stuff in bolt.. nvm...

Status right now:

  • So in general, having something comma separated is allowed by Spring Boot Actuator.
  • Spring Boot Actuator isn't very verbose when the request is not as expected. It just responds with a Bad Request

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

No branches or pull requests

2 participants