This is an automated email from the ASF dual-hosted git repository.
borisstoyanov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack-cloudmonkey.git
The following commit(s) were added to refs/heads/main by this push:
new 2218325 Fix nil panic in UpdateCache when listapisresponse is empty
(#211) (#217)
2218325 is described below
commit 2218325992529aceb060de4950e23b7e2bab33bc
Author: Rohan Mishra <[email protected]>
AuthorDate: Wed Sep 9 12:13:06 2026 +0530
Fix nil panic in UpdateCache when listapisresponse is empty (#211) (#217)
* Fix nil panic in UpdateCache when listapisresponse is empty (#211)
* Keep existing API cache when listApis returns an empty response
Move the nil guard above the cache reset so a failed sync no longer
clears the in-memory API cache, and return 0 so 'cmk sync' prints
"Discovered 0 APIs" instead of "Discovered <nil> APIs".
---------
Co-authored-by: Boris Stoyanov <[email protected]>
---
config/cache.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/config/cache.go b/config/cache.go
index 510075a..abdb28e 100644
--- a/config/cache.go
+++ b/config/cache.go
@@ -108,6 +108,11 @@ func (c *Config) SaveCache(response
map[string]interface{}) {
// UpdateCache uses auto-discovery data to update internal API cache
func (c *Config) UpdateCache(response map[string]interface{}) interface{} {
+ if response["api"] == nil {
+ fmt.Fprintf(os.Stderr, "Error: empty API list received, sync
failed. Existing API cache is kept.\n")
+ return 0
+ }
+
apiCache = make(map[string]*API)
apiVerbMap = nil