Skip to content

fix(standalone): resolve env var references in config pushed via Admin API#37

Closed
AlinsRan wants to merge 1 commit into
masterfrom
fix/standalone-admin-env-var
Closed

fix(standalone): resolve env var references in config pushed via Admin API#37
AlinsRan wants to merge 1 commit into
masterfrom
fix/standalone-admin-env-var

Conversation

@AlinsRan

Copy link
Copy Markdown
Owner

Description

Staged in fork for review before opening upstream (apache/apisix).

In standalone mode there are two config sources:

  • file (apisix.yaml) — ${{VAR}} / $ENV:// references are resolved in config_yaml.parse().
  • Admin API (PUT /apisix/admin/configs) — the JSON body is decoded straight into config_yaml._update_config(), which (since the parse-time resolution was introduced) no longer resolves those references, so they are kept literal.

This restores resolution for the Admin API path: apisix/admin/standalone.lua now calls file.resolve_conf_var(config) before applying the pushed config, so both sources behave consistently. Because the Admin API body is JSON (already typed), table-level resolution does not reintroduce the YAML type-inference issue that motivated moving resolution to parse time.

Test

Adds a case to t/admin/standalone.spec.ts: push a route whose proxy-rewrite.uri is ${{STANDALONE_ENV_TEST:=/hello}} and assert the route returns the hello body (i.e. the reference was resolved to its default; a literal value would not match).

Note: I could not run the standalone Admin-API (pnpm) suite locally — please rely on CI to validate the new test.

…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 AlinsRan force-pushed the fix/standalone-admin-env-var branch from dea16d7 to 3fa7450 Compare June 12, 2026 02:37
@AlinsRan AlinsRan closed this Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant