lxbme commented on code in PR #13078:
URL: https://github.com/apache/apisix/pull/13078#discussion_r2896608627


##########
t/cli/test_standalone.sh:
##########
@@ -155,3 +155,120 @@ if [ $expected_config_reloads -ne $actual_config_reloads 
]; then
     exit 1
 fi
 echo "passed: apisix.yaml was not reloaded"
+
+
+# test: environment variable with large number should be preserved as string
+echo '
+apisix:
+  enable_admin: false
+deployment:
+  role: data_plane
+  role_data_plane:
+    config_provider: yaml
+' > conf/config.yaml
+
+echo '
+routes:
+  -
+    uri: /test-large-number
+    plugins:
+      openid-connect:
+        client_id: "${{APISIX_CLIENT_ID}}"
+        client_secret: "secret"
+        discovery: "http://example.com/.well-known/openid-configuration";
+    upstream:
+      nodes:
+        "127.0.0.1:9091": 1
+      type: roundrobin
+#END
+' > conf/apisix.yaml
+
+# Test with large number that exceeds Lua double precision
+APISIX_CLIENT_ID="356002209726529540" make init
+
+if ! APISIX_CLIENT_ID="356002209726529540" make run > output.log 2>&1; then
+    cat output.log
+    echo "failed: large number in env var should not cause type conversion 
error"
+    exit 1
+fi
+
+sleep 0.1
+
+# Verify the service is running (should not have validation errors)
+code=$(curl -o /dev/null -s -m 5 -w %{http_code} 
http://127.0.0.1:9080/test-large-number)
+if [ $code -eq 500 ]; then
+    echo "failed: large number env var was converted to scientific notation"
+    exit 1
+fi
+
+make stop
+sleep 0.5
+
+echo "passed: large number in env var preserved as string in apisix.yaml"
+
+# test: quoted numeric env vars in apisix.yaml should remain strings
+echo '
+apisix:
+  enable_admin: false
+deployment:
+  role: data_plane
+  role_data_plane:
+    config_provider: yaml
+' > conf/config.yaml
+
+echo '
+routes:
+  -
+    uri: /test-quoted
+    plugins:
+      proxy-rewrite:
+        headers:
+          X-Custom-ID: "${{NUMERIC_ID}}"
+    upstream:
+      nodes:
+        "127.0.0.1:9091": 1
+      type: roundrobin
+#END
+' > conf/apisix.yaml
+
+NUMERIC_ID="12345" make init
+NUMERIC_ID="12345" make run
+sleep 0.1
+
+code=$(curl -s -H "Host: test.com" http://127.0.0.1:9080/test-quoted -o 
/dev/null -w %{http_code})
+if [ ! $code -eq 404 ] && [ ! $code -eq 200 ]; then

Review Comment:
   Here's a summary of the changes I'll push in the next commit:
   
   Code fix:
   
   - Updated apisix/core/config_yaml.lua: update_config() now calls 
file.resolve_conf_var(table, false) to disable type conversion when reloading 
apisix.yaml at runtime. This was the missing call site that Copilot correctly 
identified.
   - Kept the default value of enable_type_conversion as true in 
resolve_conf_var() to maintain backward compatibility, since it's an exported 
public function (_M.resolve_conf_var) and changing the default could silently 
break existing callers.
   
   Test improvements:
   
   - Replaced openid-connect plugin with response-rewrite to eliminate external 
dependencies and enable deterministic assertions.
   - Changed assertions from HTTP status code checks to exact response body 
matching (e.g., verifying 356002209726529540 is not converted to 
3.5600220972653e+17).
   - Replaced the node_listen / nginx.conf grep test with a type-sensitive 
boolean test: enable_admin: ${{ENABLE_ADMIN}} with ENABLE_ADMIN=false, 
verifying the admin API is actually disabled (proves string→boolean conversion 
works in config.yaml).



-- 
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]

Reply via email to