apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug: the plugin metadata obtained from etcd has not been validated by schema

Open nic-6443 opened this issue 1 year ago • 0 comments

Current Behavior

Part 1

We created an etcd client to handle plugin metadata in: https://github.com/apache/apisix/blob/64b81c48ed3bf4ed1bf5b2edbd4bcdea5137123c/apisix/plugin.lua#L816-L821 in check_plugin_metadata function, we need a item.id(expectation is the plugin name) to check metadata schema of specific plugin. https://github.com/apache/apisix/blob/64b81c48ed3bf4ed1bf5b2edbd4bcdea5137123c/apisix/plugin.lua#L1040-L1042 but plugin metadata don't have a id field in our admin api, so when apisix startup with a exist plugin metadata, the checker will be triggered in config_etcd:load_full_data https://github.com/apache/apisix/blob/64b81c48ed3bf4ed1bf5b2edbd4bcdea5137123c/apisix/core/config_etcd.lua#L489-L495 and then checker failed with this log: image

Part 2

When watch a new data from etcd, config_etcd.lua only check configuration that has configure with a item_schema https://github.com/apache/apisix/blob/64b81c48ed3bf4ed1bf5b2edbd4bcdea5137123c/apisix/core/config_etcd.lua#L667-L685 because plugin_metadata only set checker field without item_schema, so the new plugin metadata watch from etcd don't validate by schema too.

Expected Behavior

No response

Error Logs

No response

Steps to Reproduce

/

Environment

/

nic-6443 avatar Apr 30 '24 09:04 nic-6443