openresty / openresty/lua-nginx-module

Question about request uri args in body_filter_by_lua_block

Open
#1,368 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

Hello,

I am Proxying a request as follows (content_by_lua_file):

ngx.exec('/data/' .. value.id .. '.json', { myid = 'myid' })

Then I have the following filter block:

body_filter_by_lua_block {
                local args = ngx.req.get_uri_args()
                
                ngx.arg[1] = string.gsub(ngx.arg[1], '__replace-id__', args.myid)
            }

The filter block is added in a location that serves a static json file which should replace "replace-id" with args.myid string.

But it seems that args.myid is always nil, am I missing something or is it a bug?

Thanks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how ngx.exec('/data/' .. value.id .. '.json', { myid = 'myid' }) passes request arguments into the location containing body_filter_by_lua_block. Inspect the behavior of ngx.req.get_uri_args() there and reproduce the nil value with the shown static JSON filter; done means the argument scope and expected behavior are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, nginx
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.