Skip to content

Fix infinite recursion in etcd cache _walk on empty folders#69235

Open
ggiesen wants to merge 1 commit into
saltstack:3006.xfrom
ggiesen:fix-57377-etcd-cache-recursion
Open

Fix infinite recursion in etcd cache _walk on empty folders#69235
ggiesen wants to merge 1 commit into
saltstack:3006.xfrom
ggiesen:fix-57377-etcd-cache-recursion

Conversation

@ggiesen
Copy link
Copy Markdown
Contributor

@ggiesen ggiesen commented May 27, 2026

What does this PR do?

Fixes a SaltCacheError ("maximum recursion depth exceeded") raised by the
etcd data cache when a cache bank contains an empty folder.

etcd reports an empty folder as a child of itself, so _walk() in
salt/cache/etcd_cache.py called _walk() again on the same key and recursed
until it hit Python's recursion limit. The walk now stops when a child's key
matches the folder being walked.

What issues does this PR fix or reference?

Fixes #57377

Previous Behavior

Walking a cache bank that contained an empty folder (e.g. via cache.ls)
raised SaltCacheError: maximum recursion depth exceeded while calling a Python object.

New Behavior

The empty folder is detected and skipped, and the walk returns the keys found
without error.

Tests

salt.cache.etcd_cache had no unit tests, so this adds a suite covering
__virtual__, _init_client, store, fetch, flush, _walk (including the
empty-folder regression), ls, contains, and updated.

Merge requirements satisfied?

  • Changelog
  • Tests written/updated

Commits signed with GPG?

No

etcd reports an empty folder as a child of itself, so _walk() recursed on the
same key until it exhausted the recursion limit and raised a SaltCacheError
("maximum recursion depth exceeded"). Stop the walk when a child's key matches
the folder being walked.

Adds a unit test suite for salt.cache.etcd_cache (previously untested),
covering __virtual__, _init_client, store, fetch, flush, _walk (including the
empty-folder regression), ls, contains, and updated.

Fixes saltstack#57377
@ggiesen ggiesen force-pushed the fix-57377-etcd-cache-recursion branch from 4090b8c to 17ece9b Compare May 27, 2026 15:41
@ggiesen ggiesen changed the base branch from master to 3006.x May 27, 2026 15:41
@ggiesen
Copy link
Copy Markdown
Contributor Author

ggiesen commented May 27, 2026

Re-targeted to 3006.x (was master): this is a bug fix and 3006.x is the oldest supported branch that contains the affected salt/cache/etcd_cache.py code, per Salt's contributing guide. It will merge forward to 3007.x/3008.x/master.

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.

[BUG] SaltCacheError 'maximum recursion depth exceeded while calling a Python object' with ETCD cache

1 participant