apisix-dashboard icon indicating copy to clipboard operation
apisix-dashboard copied to clipboard

bug: 2.1 version schema-sync.sh display error when sync apisix's custom plugin.

Open idbeta opened this issue 6 years ago • 5 comments

Bug report

Describe the bug

2.1 version schema-sync.sh display error when sync apisix's custom plugin.

... ...
lua: ./apisix/plugins/batch-requests.lua:23: attempt to index a nil value (field 'string')
stack traceback:
	./apisix/plugins/batch-requests.lua:23: in main chunk
	[C]: in function 'require'
	schema-sync.lua:134: in main chunk
	[C]: in ?

idbeta avatar Nov 24 '20 09:11 idbeta

How to reproduce?

moonming avatar Nov 24 '20 10:11 moonming

How to reproduce?

ENV: dashboard and APISIX are both 2.1 STEPS:

  1. build the dashbaord 2.1 with source codes
  2. create a custom plugin
  3. enable the custom plugin by the config.yaml
  4. check whether the plugin is successfully enabled from etcd
/apisix/plugins
[... ...,{"name":"custom_plugin"}, ... ...]
  1. use the schema-sync.sh sync the schema.json
api/build-tools/schema-sync.sh /my-real-path/to/apisix
  1. it will output the error message
... ...
lua: ./apisix/plugins/batch-requests.lua:23: attempt to index a nil value (field 'string')
stack traceback:
	./apisix/plugins/batch-requests.lua:23: in main chunk
	[C]: in function 'require'
	schema-sync.lua:134: in main chunk
	[C]: in ?

idbeta avatar Nov 24 '20 14:11 idbeta

batch-requests is not a custom plugin.

moonming avatar Nov 25 '20 05:11 moonming

that is a bug, confirmed.

https://github.com/apache/apisix-dashboard/blob/master/api/build-tools/schema-sync.lua#L55-L56

here is a way we can make a try:

local t_idx = {
    __index = function (t, key)
        local val = {}
        rawset(t, key, val)
        return val
   end
}

package.loaded['apisix.core'] = {
    __index = t_idx
}

membphis avatar Nov 25 '20 07:11 membphis

https://github.com/apache/apisix-dashboard/commit/cdab40954340d37c94a5e7e6fecf41a4020e2570#diff-89ff393b58f42ba20bebfddf49f17dc9652e90d21a47a10727da861c16b3fdabR110-R111

fixed this issue

membphis avatar Nov 30 '20 09:11 membphis