nic-6443 commented on issue #12932:
URL: https://github.com/apache/apisix/issues/12932#issuecomment-4222017590
I took a deeper look at this issue and #13078. The current fix
(`exceeds_lua_precision` — only skip `tonumber()` for integers >15 digits)
doesn't actually solve the original problem. Even small numeric strings like
`client_id: "${{VAR}}"` with `VAR=12345` would still be converted to number
`12345`, failing schema validation when the field expects a string.
The root cause is that `resolve_conf_var()` does env var substitution
**after** YAML parsing. At that point, YAML quotes are already gone — both
`"${{VAR}}"` and `${{VAR}}` become the same Lua string `${{VAR}}`. So there's
no way to tell whether the user intended a string or a number.
I think the right fix is to do the substitution **before** YAML parsing —
replace `${{VAR}}` in the raw YAML text first, then let `yaml.load()` handle
types naturally:
```yaml
client_id: "${{VAR}}" # VAR=12345 → "12345" → string ✓
retries: ${{RETRIES}} # RETRIES=3 → 3 → number ✓
http_to_https: ${{FLAG}} # FLAG=true → true → boolean ✓
```
Quoted = string, unquoted = YAML decides. Same approach Helm uses. Only
applies to `apisix.yaml`, `config.yaml` stays unchanged. The change is small —
~25 lines for a new function + 2 call sites.
Happy to submit a PR if this direction makes sense.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]