The design of the Admin API is now such that if an incorrect parameter name is submitted, this property (if not required) will be ignored, then execution continues, and the response is “204 Success”. This will trick the user into thinking the setup succeeded when it didn't correctly as expected in some cases, as shown below:
User POST request to /{tenant}/{namespace}/{topic}/retention" with incorrect parameter:
{"retention_size_in_mb":-1,"retention_time_in_minutes":40320}
Which should have been this:
{"retentionSizeInMB":-1,"retentionTimeInMinutes":40320}
Response:
HTTP/1.1 204 No Content Date: Mon, 20 Jun 2022 02:54:25 GMT broker-address: 127.0.0.1 Server: Jetty(9.4.44.v20210927)
We can provide an optional mechanism: “fail (HTTP status 400 bad requests) on unknown request parameters”.
When parsing the request body, any unknown property is considered a bad request. The Jackson unknown property rule is adopted:
If the check fails, return a text/plain response with 400 code. Like this:
HTTP/1.1 400 Bad Request Date: Mon, 20 Jun 2022 03:52:10 GMT broker-address: 127.0.0.1 Content-Type: text/plain Content-Length: 432 Server: Jetty(9.4.44.v20210927) Unrecognized field "retention_size_in_mb" (class org.apache.pulsar.common.policies.data.RetentionPolicies known properties: "retentionSizeInMB", "retentionTimeInMinutes"])
broker.conf
# Admin API fail on unknown request parameter in request-body. see PIP-178. Setting this to blank means that this feature is turned off. httpRequestsFailOnUnknownPropertiesEnabled=false
Enabling this feature affects all of the broker's HTTP services, including the following:
Because of the number of apis involved, we provide dynamic configuration. When a user discovers any problem, it can be turned on and off dynamically using the Admin API(without restarting Broker), which can reduce impact.
pulsar-admin brokers update-dynamic-config --config httpRequestsFailOnUnknownPropertiesEnabled --value [boolean]
Note: Since admin api v1 is no longer maintained, this feature does not affect this part of the functionality.