Current Behavior
This issue summurizes #8719 which was reported for the same behaviour.
If you configure proxy-cache plugin with ONLY "cache_strategy": "memory", you get a 500 Internal Server Error
$ curl http://127.0.0.1:9180/apisix/admin/routes/1 \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/ip",
"plugins": {
"proxy-cache": {
"cache_strategy": "memory",
"cache_ttl": 10
}
},
"upstream": {
"nodes": {
"httpbin.org": 1
},
"type": "roundrobin"
}
}'
$ curl -i http://127.0.0.1:9080/ip
<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>openresty</center>
<p><em>Powered by <a href="https://apisix.apache.org/">APISIX</a>.</em></p></body>
</html>
Logs:
[error] 128#128: *7943331 lua entry thread aborted: runtime error: ./apisix/plugins/proxy-cache/memory.lua:47: attempt to index field 'dict' (a nil value)
stack traceback:
coroutine 0:
./apisix/plugins/proxy-cache/memory.lua: in function 'get'
./apisix/plugins/proxy-cache/memory_handler.lua:204: in function 'phase_func'
./apisix/plugin.lua:1099: in function 'run_plugin'
./apisix/init.lua:674: in function 'http_access_phase'
access_by_lua(nginx.conf:340):2: in main chunk, client: 192.168.112.1, server: _, request: "POST /api HTTP/1.1", host: "127.0.0.1:9080"
The correct usage is to configure "cache_strategy": "memory"with "cache_zone": "memory_cache" (or any other custom memory cache zones defined in config.yaml), such as the below:
"proxy-cache": {
"cache_strategy": "memory",
"cache_zone": "memory_cache"
}
Expected Behavior
If a user incorrectly configure just the "cache_strategy": "memory" without specifying a memory zone, the program should return an error message to help users identify the issue, instead of crashing like the current behaviour.
Suggested Fix
Environment
APISIX version (run apisix version): 3.4.0
Current Behavior
This issue summurizes #8719 which was reported for the same behaviour.
If you configure
proxy-cacheplugin with ONLY"cache_strategy": "memory", you get a500 Internal Server ErrorLogs:
The correct usage is to configure
"cache_strategy": "memory"with"cache_zone": "memory_cache"(or any other custom memory cache zones defined inconfig.yaml), such as the below:Expected Behavior
If a user incorrectly configure just the
"cache_strategy": "memory"without specifying a memory zone, the program should return an error message to help users identify the issue, instead of crashing like the current behaviour.Suggested Fix
cache_strategy, nor does it warn users of configuring the propercache_zonefor in-memorycache_strategy.Environment
APISIX version (run
apisix version): 3.4.0