openresty / openresty/lua-nginx-module

configuration file parsing fails when content_by_lua_block has long string

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

version: openresty/1.15.8.2

It's ok to have short lua string inside content_by_lua_block:

location / {
  content_by_lua_block {
    local s = [[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]]
  }
}

But if the string is long enough, more than 4000 in my case, configuration parsing fails:

location / {
  content_by_lua_block {
    local s = [[aaaaaaaaaa(many many characters, more than 4000 as)aaaaaaaaaaaaaaaaaaaaaa]]
  }
}
$ sbin/nginx -t
2020/02/12 15:20:29 [emerg] 56#56: Lua code block missing the closing long bracket "]]" in /usr/local/openresty/nginx/conf/nginx.conf:22
nginx: [emerg] Lua code block missing the closing long bracket "]]" in /usr/local/openresty/nginx/conf/nginx.conf:22
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test failed

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

Reproduce the failure with the content_by_lua_block example in nginx.conf and run sbin/nginx -t. Trace the configuration parsing entry point for content_by_lua_block, then verify that a Lua long string exceeding 4000 characters parses successfully and that the configuration test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua, nginx
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.