Skip to content

[Bug] APISix 3.13.0 - balancer.lua:328: set_current_peer expects string but gets table #12545

@khrism

Description

@khrism

Current Behavior

APISix 3.13.0 fails to process upstream nodes configuration with error: bad argument #3 to 'set_current_peer' (string expected, got table) at balancer.lua:328.

Additional Info:

Echo plugin works perfectly (no upstream needed)

Admin API fully functional

etcd integration working

Issue occurs with both hostname and IP upstream nodes

Service-based approach also fails with same error

Expected Behavior

No response

Error Logs

2025/08/23 05:24:25 [error] 16117#16117: 11337 failed to run balancer_by_lua: /usr/local/openresty/lualib/ngx/balancer.lua:159: bad argument #3 to 'set_current_peer' (string expected, got table)
stack traceback:
[C]: in function 'error'
/usr/local/openresty/lualib/ngx/balancer.lua:159: in function 'set_current_peer'
/home/khris/apisix/balancer.lua:328: in function 'set_current_peer'
/home/khris/apisix/balancer.lua:386: in function 'run'
/home/khris/apisix/init.lua:983: in function 'http_balancer_phase'

Steps to Reproduce

  1. Create route with upstream:
curl -X PUT http://127.0.0.1:9180/apisix/admin/routes/1 \
  -H "X-API-KEY: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "uri": "/test",
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "httpbin.org:80": 1
        }
    }
}'
Access route: curl http://127.0.0.1:9080/test

Results in 500 error

### Environment

- APISix: 3.13.0
- OS: Ubuntu 22.04
- OpenResty: [output from nginx -v]
- etcd: 3.5.0
- LuaJIT: [output from luajit -v]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions