Skip to content

bug: proxy-cache plugin generate_complex_value may fail due to concat nil values #7167

@worldwonderer

Description

@worldwonderer

Current Behavior

if proxy-cache plugins configures cache_key with ["$arg_a", "$arg_b"] and $arg_a and $arg_b are both nil, apisix will abort with error.

I think it is quite normal that api has not required args, can this line tmp[i] = ctx.var[string.sub(value, 2)] change to tmp[i] = ctx.var[string.sub(value, 2)] or ""? if it is acceptable, i would like to submit a PR.

Expected Behavior

cache_key not fail with nil variables

Error Logs

[error] 3329653#3329653: *15666726 lua entry thread aborted: runtime error: ...tion/bin/apisix/plugins/proxy-cache.lua:149: invalid value (nil) at index 2 in table for 'concat'

Steps to Reproduce

create route with proxy-cache plugin, and configure cache key with "cache_key": ["$arg_a", "$arg_b"] and then request without url args

Environment

  • APISIX version (run apisix version):2.11.0
  • Operating system (run uname -a):Linux 11-186-252-137 4.14.105-1-tlinux3-0016 change: added doc of how to load plugin. #1 SMP Fri Jul 31 16:16:47 CST 2020 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version (run openresty -V or nginx -V):nginx version: openresty/1.19.9.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions