Skip to content

bug: Attempt to index field 'plugins' Error, when configuring route and referencing services with DNS. #954

Description

@sshniro

Issue description

I'm trying to create a service and reference it in a route. The following are my configurations:

curl "http://127.0.0.1:9080/apisix/admin/services/200" -X PUT -d '
{
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "httpbin.org:443": 1
        }
    }
}'
curl "http://127.0.0.1:9080/apisix/admin/routes/1" -X PUT -d '
{
    "uri": "/get",
    "host": "httpbin.org",
    "plugins": {
                "proxy-rewrite": {
                        "scheme": "https"
                    
                }
            },
    "service_id": "200"
}'
curl -i -X GET "http://127.0.0.1:9080/get" -H "Host: httpbin.org"

What's the actual result? (including assertion message & call stack if applicable)

When I call the endpoint it gives a 500 Internal server error.
image

The following are the error logs.

2019/12/09 10:08:31 [error] 29#29: *80103 lua entry thread aborted: runtime error: ...l/apisix/deps/share/lua/5.1/apisix/lua/apisix/plugin.lua:306: attempt to index field 'plugins' (a nil value)
stack traceback:
coroutine 0:
        ...l/apisix/deps/share/lua/5.1/apisix/lua/apisix/plugin.lua: in function 'create_obj_fun'
        ...x/deps/share/lua/5.1/apisix/lua/apisix/core/lrucache.lua:64: in function 'merge_service_route'
        /usr/local/apisix/deps/share/lua/5.1/apisix/lua/apisix.lua:287: in function 'http_access_phase'
        access_by_lua(nginx.conf:139):2: in main chunk, client: 127.0.0.1, server: , request: "GET /get?foo1=bar1&foo2=bar2 HTTP/1.1", host: "httpbin.org"

What's the expected result?

It should return the actual results.

The contradicting behavior is, if I configure everything in a route then I can access the endpoint without any problems.

curl http://127.0.0.1:9080/apisix/admin/routes/1 -X PUT -d '
{
    "uri": "/get",
    "plugins": {
        "proxy-rewrite": { "scheme": "https" }
    },
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "httpbin.org:443": 1
        }
    }
}'

image

Is this an expected behavior? Or am I doing something wrong here?

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions