GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [PIP-179] Support the admin API to check unknown request parameters · Issue #16135 · apache/pulsar

[PIP-179] Support the admin API to check unknown request parameters #16135

New issue
Copy link
New issue
Copy link
Closed
Closed
[PIP-179] Support the admin API to check unknown request parameters#16135
Copy link
Labels
type/PIP

Description

@poorbarcode
poorbarcode
opened on Jun 20, 2022
Issue body actions

Motivation

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

Goal

  • scope:
    • Path variables(no need for change): This represents the domain. The current API has been validated, so no additional modifications are required.
    • Query params(no support on this proposal): I haven't found an elegant way to do it yet, so this proposal does not include Query Param validation.
    • Entity properties: This proposal only handles requests whose Content-type is "application/json" (in fact, this is the only type in our project).
  • Configurable(Support dynamic switching).

Approach

When parsing the request body, any unknown property is considered a bad request. The Jackson unknown property rule is adopted:

  • Case sensitive.
  • Special characters are not ignored.
  • Do not trim Spaces.

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"])

Configuration Changes

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

Dynamic switching

Enabling this feature affects all of the broker's HTTP services, including the following:

  • /status.html (no post-entity request)
  • /admin [v2,v3]
  • /lookup (no post-entity request)
  • /topics (http client)
  • /metrics (no post-entity request)

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.

Activity

  1. poorbarcode
    added
    type/PIP
    on Jun 20, 2022
  2. poorbarcode
    changed the title [-][PIP-178] Support admin API fail on unknown request parameter[/-] [+][PIP-178] Support the admin API to check unknown request parameter[/+] on Jun 20, 2022
  3. poorbarcode
    changed the title [-][PIP-178] Support the admin API to check unknown request parameter[/-] [+][PIP-178] Support the admin API to check unknown request parameters[/+] on Jun 20, 2022
  4. Jason918 commented on Jun 21, 2022

    @Jason918
    Jason918
    on Jun 21, 2022
    Contributor
    More actions

    PIP ID is used by #16042

  5. poorbarcode
    changed the title [-][PIP-178] Support the admin API to check unknown request parameters[/-] [+][PIP-179] Support the admin API to check unknown request parameters[/+] on Jun 21, 2022
  6. poorbarcode commented on Jun 21, 2022

    @poorbarcode
    poorbarcode
    on Jun 21, 2022
    ContributorAuthor
    More actions

    PIP ID is used by #16042

    I have corrected it. Thanks

  7. poorbarcode commented on Jun 22, 2022

    @poorbarcode
    poorbarcode
    on Jun 22, 2022
    ContributorAuthor
    More actions

    Discuss Link: https://lists.apache.org/thread/m8vkxl46njm7sh0r1mqsn25jggq9v8kb
    Vote link: https://lists.apache.org/thread/tm77qz8g1fj0gkxf7j7o0kqfff9226n6

  8. poorbarcode commented on Jul 28, 2022

    @poorbarcode
    poorbarcode
    on Jul 28, 2022
    ContributorAuthor
    More actions

    complete.

  9. poorbarcode
    closed this as completedon Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/PIP

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.