openresty / openresty/lua-nginx-module

ngx.var.request_uri is sometimes nil

Open
#1,648 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

We sometimes get an unhandled exception thrown to our nginx/error.log when we try to read ngx.var.request_uri and manipulate it, for example:

2020/02/13 13:06:48 [error] 11893#0: *195814 [lua] logger.lua:166: warning(): failed to post to rollbar because ./rollbar.lua:125: attempt to concatenate field 'request_uri' (a nil value) while logging request, client: 123.456.12.3, server: myapp.com request: "{}"

This is corresponding to local url = ngx.var.scheme .. '://' .. ngx.var.host .. ngx.var.request_uri.

I'm not sure how ngx.var.request_uri can ever be nil? Under what condition does this happen?

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.var.request_uri is exposed and handled in the module, then compare that behavior with the accesses shown at logger.lua:166 and rollbar.lua:125. Reproduce or identify the condition that yields nil, and consider the issue done when that condition and the expected behavior are established.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.