Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/extension/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _collect(path, depth=0, max_depth=3):
for item in os.listdir(path):
_collect(os.path.join(path, item), depth + 1, max_depth)
for source in DEV_EXTENSION_SOURCES:
_collect(source)
_collect(source, max_depth=2)
Comment on lines 268 to +271
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

Passing max_depth=2 here prevents discovery of *.egg-info directories that are exactly 2 levels below source. _collect returns immediately when depth == max_depth (before running the glob), so with source/src/<ext>/*.egg-info the <ext> directory is reached at depth=2 and will be skipped entirely. Consider either keeping max_depth=3, or changing _collect so the depth limit is enforced only for recursion (e.g., allow processing at depth == max_depth but don’t descend further).

Copilot uses AI. Check for mistakes.
Comment on lines 270 to +271
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

This change alters dev extension discovery behavior, but the existing core extension tests (e.g., src/azure-cli-core/azure/cli/core/tests/test_extension.py) don’t appear to cover DevExtension.get_all() or DEV_EXTENSION_SOURCES. Adding a focused unit test that sets DEV_EXTENSION_SOURCES to a temp directory and verifies discovery for layouts at depth 1 and depth 2 would prevent regressions around the depth limit.

Copilot uses AI. Check for mistakes.
# https://docs.python.org/3/library/os.html#os.listdir, listdir is in arbitrary order.
# Sort the extensions by name to support overwrite extension feature: https://github.com/Azure/azure-cli/issues/25782.
exts.sort(key=lambda ext: ext.name)
Expand Down
Loading