Skip to content

bug: Error during consul discovery synchronization when port field is missing in Consul service #11959

@zkx5xkt

Description

@zkx5xkt

Current Behavior

When Consul discovery is enabled, an error occurs during service synchronization from Consul (attempt to concatenate local 'svc_port' (a nil value)) if not all services in Consul contain the port field.
This leads to the issue where APISIX Consul discovery does not add any services at all.

The error happens here

Expected Behavior

In Consul, the only mandatory field when registering a service is name. Therefore, services that cannot be added to the APISIX discovery should be skipped.

Error Logs

2025/02/10 03:57:40 [error] 32#32: *54 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/discovery/consul/init.lua:525: attempt to concatenate local 'svc_port' (a nil value)

Steps to Reproduce

  1. run consul, register service only with name provided
  2. enable consul discovery in apisix
  3. run apisix via docker image

Environment

  • APISIX version (run apisix version): 3.11.0
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

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