Skip to content

fix: handle missing resource config in node version helpers - #13986

Open
j1sk1ss wants to merge 1 commit into
apache:masterfrom
j1sk1ss:fix-resource-nodes-ver-missing-conf
Open

j1sk1ss wants to merge 1 commit into
apache:masterfrom
j1sk1ss:fix-resource-nodes-ver-missing-conf

Conversation

@j1sk1ss

@j1sk1ss j1sk1ss commented Sep 24, 2026 •

Copy link
Copy Markdown

Description

fetch_latest_conf can return nil when the referenced resource has already been deleted. get_nodes_ver and set_nodes_ver_and_nodes used the returned value immediately, which could raise an attempt to index a nil value.

This PR adds nil guards for that case. get_nodes_ver now returns nil when the latest resource config is unavailable, and set_nodes_ver_and_nodes exits without updating nodes when the resource no longer exists.

Which issue(s) this PR fixes:

Fixes #

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)

Found this with Svace static analyzer

@ruanweihong-aaa

Copy link
Copy Markdown
Contributor

Thanks for the fix! The two nil guards look good. Could you add regression tests for both helpers when the resource does not exist? Also, please add the fix: prefix to the PR title, for example: fix: handle missing resource config in node version helpers.

@j1sk1ss j1sk1ss changed the title Handle missing resource config in node version helpers fix: handle missing resource config in node version helpers Oct 23, 2026
@j1sk1ss
j1sk1ss force-pushed the fix-resource-nodes-ver-missing-conf branch from dba983f to dc7c2b6 Compare October 23, 2026 12:31
@j1sk1ss

j1sk1ss commented Oct 23, 2026

Copy link
Copy Markdown
Author

Added a regression test and changed the title

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.

2 participants