Skip to content

bug: String environment variable value is casted tonumber if contains a number in standalone mode #12932

@ravillarreal

Description

@ravillarreal

Current Behavior

Im using apisix, with standalone mode, in which ive noticed that when a env variable is set in apisix.yaml file, if the value is a number, it will automatically convert it to number, and this causes an error if the number is bigger than Lua's double, for example (extracted from my apisix.yaml file):

plugin_configs:
  - id: 1
    plugins:
      openid-connect:
        client_id: "${{APISIX_OIDC_CLIENT_ID}}"

Note the double " in the env var, still it doesnt treat it like an string

The APISIX_OIDC_CLIENT_ID is set to "356002209726529540" but the value is casted to "client_id":3.5600220972653e+17

This is because this code in apisix/cli/file.lua

if tonumber(new_val) ~= nil then

Expected Behavior

I expect that the value passed in as "${{var}}" works like an string

Error Logs

2026/01/22 06:11:11 [error] 57#57: *321192 [lua] config_yaml.lua:333: failed to check item data of [plugin_configs] err:failed to check the configuration of plugin openid-connect err: property "client_id" validation failed: wrong type: expected string, got number ,val:

Steps to Reproduce

  1. Run APISIX via the docker image
  2. Configure it as standalone mode with env variable - APISIX_DEPLOYMENT_MODE=standalone
  3. Configure env variable with number inside bigger than lua's double eg "356002209726529540"
  4. Set the variable in apisix.yaml in "${{}}" format
  5. Get the error, in this case im using openid-connect plugin

Environment

  • APISIX version (run apisix version): image: apache/apisix:3.14.1-debian
  • Operating system (run uname -a): fedora 43 workstation
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info): standalone mode
  • 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

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

Status

🏗 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions