Open
Description
Is there an existing issue for this?
No, I have searched the existing issues (query: "attempt to call method 'lower'"
)
Related issue: Kong/kong#14187
Version
I am using the docker image kong:3.9.0-ubuntu
# luarocks show lapis
kong-lapis 1.16.0.1-1 - A fork of leafo/lapis for Kong
License: MIT
Installed in: /usr/local
Error
Logs from netcat:
HTTP/1.1 500 Internal Server Error
Date: Fri, 17 Jan 2025 13:31:20 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: http://localhost:8002
X-Kong-Admin-Request-ID: c18cf71ef5ecf01b7fcc0d1fa9eaaa3e
vary: Origin
Access-Control-Allow-Credentials: true
Content-Length: 42
X-Kong-Admin-Latency: 8
Server: kong/3.9.0.0-enterprise-edition
{"message":"An unexpected error occurred"}%
Logs from server:
2025/01/17 13:31:20 [error] 2550#0: *11300 [lua] api_helpers.lua:541: handle_error(): /usr/local/share/lua/5.1/lapis/application.lua:440: /usr/local/share/lua/5.1/lapis/application.lua:488: attempt to call method 'lower' (a nil value)
stack traceback:
/usr/local/share/lua/5.1/lapis/application.lua: in function </usr/local/share/lua/5.1/lapis/application.lua:484>
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/lapis/application.lua:440: in function 'handler'
/usr/local/share/lua/5.1/lapis/application.lua:186: in function 'resolve'
/usr/local/share/lua/5.1/lapis/application.lua:217: in function </usr/local/share/lua/5.1/lapis/application.lua:215>
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/lapis/application.lua:215: in function 'dispatch'
/usr/local/share/lua/5.1/lapis/nginx.lua:231: in function 'serve'
/usr/local/share/lua/5.1/kong/init.lua:2130: in function 'admin_content'
content_by_lua(nginx-kong.conf:447):2: in main chunk, client: 172.17.0.1, server: kong_admin, request: "GET / HTTP/1.1", host: "127.0.0.0"
The trace from the server relates to the lapis, so I have created the issue in this repository instead of Kong.
Steps to reproduce
The start.sh
file (based on the docker image documentation):
#! /bin/bash
set -ue
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
MOUNT_DIR="$SCRIPT_DIR/kong-vol"
docker run -it --name kong-dbless \
-v "$MOUNT_DIR:/kong/declarative/" \
-e "KONG_DATABASE=off" \
-e "KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml" \
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001" \
-e "KONG_ADMIN_GUI_URL=http://localhost:8002" \
-e KONG_LICENSE_DATA \
-p 9000:8000 \
-p 9001:8001 \
-p 9002:8002 \
-p 9003:8003 \
-p 9004:8004 \
kong/kong-gateway:3.9.0.0
The Packet packet.txt
(two empty lines at the end. The line-endings must be CRLF):
GET / HTTP/1.1
Accept: */*
Host: 127.0.0.0
Content-Type: application/x-www-form-urlencoded
Content-Type: application/x-www-form-urlencoded
The send.sh
script:
#! /bin/bash
set -ue
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PACKETS_DIR="$SCRIPT_DIR/packets"
cat "$PACKETS_DIR/$1" | netcat 127.0.0.1 9001 &
sleep 2
kill %1
Steps:
- Run kong using
bash start.sh
- Run
bash send.sh packet.txt
Misc
As I can see, lower
method expects string in content_type
variable (and receives it, if there is only one header with key Content-Type
). However, if multiple lines Content-Type: ...
provided, the content_type
variable will contain a table.
Related source code:
Metadata
Metadata
Assignees
Labels
No labels