Repository navigation
Conversation
AlinsRan
force-pushed
the
fix/standalone-admin-env-var
branch
from
June 12, 2026 06:39
3fa7450 to
dd45c6a
Compare
…n API
In standalone mode, the file-based config path resolves ${{VAR}} / $ENV://
references in config_yaml.parse(), but config pushed through the Admin API
(`PUT /apisix/admin/configs`) is JSON-decoded straight into _update_config
and bypassed that step, so the references were kept literal.
Resolve them in the Admin API update path before applying the config, so
both standalone config sources behave consistently. Adds a test that pushes
a route whose proxy-rewrite uri uses a ${{VAR:=default}} reference and
verifies the gateway resolves it.
Signed-off-by: AlinsRan <alinsran@apache.org>
AlinsRan
force-pushed
the
fix/standalone-admin-env-var
branch
from
June 12, 2026 08:45
dd45c6a to
83204eb
Compare
|
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions. |
|
This pull request/issue has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
… file A YAML body is now substituted before it is parsed, so that quoting decides the type of a resolved value as it does in apisix.yaml; a JSON body is still resolved after decoding. The resolution moves to the parse step, which is where the file path does it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
In standalone mode,
${{VAR}}references in config pushed via the Admin API are stored literally (never resolved), so a reference in a pattern-constrained field (e.g.proxy-rewrite.uri) is even rejected with 400.Cause
Standalone has two config sources; only the file path resolves
${{VAR}}:apisix.yaml): resolved incore/config_yaml.luaparse(), before schema validation.admin/standalone.luaupdate()): validates and stores the request body without ever callingresolve_conf_var.The divergence was introduced by #13078, which moved resolution into the file-parse path only.
Fix
update()now resolves${{VAR}}while parsing the body, the same way the file path does for each format:application/yaml:file.resolve_conf_var_in_text()on the raw text beforeyaml.load, so YAML quoting decides the type, as inapisix.yaml(retries: ${{N}}is an integer,desc: "${{N}}"stays a string).file.resolve_conf_var()after decoding, which coerces resolved scalars to their native type (e.g."2"->2), as forapisix.json.Both the schema check and the stored config see resolved values, and an unresolvable reference (no env var, no
:=default) fails with 400 instead of being stored literally.Scope: this resolves the
${{VAR}}syntax only.$ENV:///$secret://references are a separate, lazily-resolved mechanism and are unaffected.Test
t/admin/standalone.spec.ts,Variable resolution:${{VAR:=default}}inproxy-rewrite.uriresolves and the route returns the hello body (a literal value would not match);${{VAR:=2}}into the integerupstream.retriesreturns 202 (native-type coercion; a literal"2"would fail integer validation);retries: ${{VAR:=2}}and a quoteddesc: "${{VAR:=123}}"returns 202, and the dump showsretriesas2anddescas"123";${{VAR}}returns 400 withfailed to resolve variables in config.All four fail against
master'sapisix/admin/standalone.luaand pass with this change.Checklist