bug: 2.1 version schema-sync.sh display error when sync apisix's custom plugin.
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 ?
How to reproduce?
How to reproduce?
ENV: dashboard and APISIX are both 2.1 STEPS:
- build the dashbaord 2.1 with source codes
- create a custom plugin
- enable the custom plugin by the
config.yaml - check whether the plugin is successfully enabled from etcd
/apisix/plugins
[... ...,{"name":"custom_plugin"}, ... ...]
- use the
schema-sync.shsync the schema.json
api/build-tools/schema-sync.sh /my-real-path/to/apisix
- 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 ?
batch-requests is not a custom plugin.
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
}
https://github.com/apache/apisix-dashboard/commit/cdab40954340d37c94a5e7e6fecf41a4020e2570#diff-89ff393b58f42ba20bebfddf49f17dc9652e90d21a47a10727da861c16b3fdabR110-R111
fixed this issue