Skip to content

fix: old entry with unresolved variable name doesn't deletes from config table after var value substitution#12885

Open
pronchakov wants to merge 1 commit intoapache:masterfrom
pronchakov:issue/12884/pulling-env-vars-in-yaml-keys-works-but-results-in-error-message-in-logs
Open

fix: old entry with unresolved variable name doesn't deletes from config table after var value substitution#12885
pronchakov wants to merge 1 commit intoapache:masterfrom
pronchakov:issue/12884/pulling-env-vars-in-yaml-keys-works-but-results-in-error-message-in-logs

Conversation

@pronchakov
Copy link
Copy Markdown

Description

There is a little bug in function local function resolve_conf_var(conf) in cli/file.lua
conf.key = nil deletes entry from conf with name "key"
but after variable substitution, old entry with name contained in variable key should be removed.
so it needs to be rewritten to conf[key] = nil

conf.key = nil results in adding entry with resolved variable to conf, but doesn't remove entry with unresolved variable name.
In case of using it in routes->upstream->nodes it results in two node entries. one is correct and one with unresolved variable name in it, that results in dns error in logs. I suppose that another places will result in different consequences.

Which issue(s) this PR fixes:

Fixes #12884

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jan 9, 2026
@Baoyuantop
Copy link
Copy Markdown
Contributor

Hi @pronchakov, can you add corresponding tests for this fix?

@pronchakov
Copy link
Copy Markdown
Author

Hi @pronchakov, can you add corresponding tests for this fix?

Ok, I'll add some tests.

@Baoyuantop Baoyuantop added the wait for update wait for the author's response in this issue/PR label Jan 20, 2026
Copy link
Copy Markdown
Member

@moonming moonming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pronchakov, thank you for catching this bug!

This is a clear and correct fix — conf.key = nil should be conf[key] = nil. The current code sets a literal field named key to nil instead of deleting the dynamic key. Great catch!

One request: Could you please add a test case that verifies this behavior? Something like:

  • Define a route/config where a key name contains an environment variable reference (e.g., \${{ENV_KEY_NAME}})
  • Verify that after resolution, the old key is properly removed and the new key exists

This is a one-line fix with clear correctness, so once the test is added, this should be ready to merge. Thank you!

@Baoyuantop
Copy link
Copy Markdown
Contributor

Hi @pronchakov, following up on the previous review comments. Please let us know if you have any updates. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files. wait for update wait for the author's response in this issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: pulling env vars in yaml keys works, but results in error message in logs

3 participants