Skip to content

Admin API: Plugins URL Query subsystem #9577

Description

@kayx23

Current Behaviours

There are 77 "HTTP" / L7 plugins:

curl -s "http://127.0.0.1:9180/apisix/admin/plugins?all=true" | jq 'length'
77

By default, if subsystem is not specified, the response defaults to returning L7 plugins. This can be validated with:

curl -s "http://127.0.0.1:9180/apisix/admin/plugins?all=true&subsystem=http" | jq 'length'
77

If we want to get stream plugins, we use subsystem=stream to query:

curl -s "http://127.0.0.1:9180/apisix/admin/plugins?all=true&subsystem=stream" | jq 'length'
4

Issue 1

If you pass other random strings into the subsystem query, it still defaults to the result for http:

curl "http://127.0.0.1:9180/apisix/admin/plugins?all=true&subsystem=strm" | jq 'length'
77
curl "http://127.0.0.1:9180/apisix/admin/plugins?all=true&subsystem=htt" | jq 'length'
77
curl "http://127.0.0.1:9180/apisix/admin/plugins?all=true&subsystem=random" | jq 'length'
77

While this may or may not be the intended behaviour, it is not very straightforward. I personally think it makes sense to add a checker to see if the subsystem value is valid (i.e. http or stream)

For example:

$ curl "http://127.0.0.1:9180/apisix/admin/plugins?all=random"
{"error_msg":"not found plugin name"}

Issue 2

There seems to be no way to get ALL plugins (L7 & L4). I expected /apisix/admin/plugins?all=true to return all plugins but instead it defaults to HTTP.

In short,

curl -s "http://127.0.0.1:9180/apisix/admin/plugins?all=true" | jq 'length'
77

seems to be the same as

curl -s "http://127.0.0.1:9180/apisix/admin/plugins?all=true&subsystem=http" | jq 'length'
77

Can anybody help me understand why this is the way?

Environment

APISIX version: 3.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions