Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compact_aaz.py fails if path is too long #27923

Open
bebound opened this issue Nov 27, 2023 · 1 comment
Open

compact_aaz.py fails if path is too long #27923

bebound opened this issue Nov 27, 2023 · 1 comment
Assignees
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team feature-request
Milestone

Comments

@bebound
Copy link
Contributor

bebound commented Nov 27, 2023

Describe the bug

This script fails if the azure-cli repo's path is long.

DEBUG:__main__:Writing python file C:\Users\kkxxxxx\Developer\azure-cli\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\command_modules\network\aaz_compact\latest\network\application_gateway\waf_policy\custom_rule\match_condition\__init__.py
Traceback (most recent call last):
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 464, in <module>
    compactor.compact()
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 157, in compact
    self.compact_sub_resource_groups(ctx, profile_mod_name)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 187, in compact_sub_resource_groups
    self.compact_resource_group(ctx, sub_dir)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 200, in compact_resource_group
    self.compact_sub_resource_groups(ctx, dirs)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 187, in compact_sub_resource_groups
    self.compact_resource_group(ctx, sub_dir)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 200, in compact_resource_group
    self.compact_sub_resource_groups(ctx, dirs)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 187, in compact_sub_resource_groups
    self.compact_resource_group(ctx, sub_dir)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 200, in compact_resource_group
    self.compact_sub_resource_groups(ctx, dirs)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 187, in compact_sub_resource_groups
    self.compact_resource_group(ctx, sub_dir)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 200, in compact_resource_group
    self.compact_sub_resource_groups(ctx, dirs)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 187, in compact_sub_resource_groups
    self.compact_resource_group(ctx, sub_dir)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 199, in compact_resource_group
    self.compact_resource_group_commands(ctx, dirs)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 261, in compact_resource_group_commands
    self._write_py_file(os.path.join(compact_folder, '__init__.py'), content=init_content)
  File "C:\Users\kkxxxxx\Developer\azure-cli\scripts\compact_aaz.py", line 173, in _write_py_file
    py_compile.compile(path)
  File "py_compile.py", line 172, in compile
  File "<frozen importlib._bootstrap_external>", line 191, in _write_atomic
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\kkxxxxx\\Developer\\azure-cli\\build_scripts\\windows\\artifacts\\cli\\Lib\\site-packages\\azure\\cli\\command_modules\\network\\aaz_compact\\latest\\network\\application_gateway\\waf_policy\\custom_rule\\match_condition\\__pycache__\\__init__.cpython-311.pyc.2276667489168'

This is similar to this bug https://bugs.python.org/issue14599, which is triggered by the long import path.
C:\Users\kkxxxxx\Developer\azure-cli\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\command_modules\network\aaz_compact\latest\network\application_gateway\waf_policy\custom_rule\match_condition\__pycache__\__init__.cpython-311.pyc.2276667489168 is 261 chars, which greater than the Maximum Path Length Limitation 260 on Windows.
(If you want to write that file in Python, the same error is raised)

If aaz\latest\network\application_gateway\waf_policy\custom_rule\match_condition folder is renamed to aaz\latest\network\application_gateway\waf_policy\custom_rule\match, the error disappears.

@bebound bebound added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Nov 27, 2023
@yonzhan
Copy link
Collaborator

yonzhan commented Nov 27, 2023

Thank you for opening this issue, we will look into it.

@yonzhan yonzhan added this to the Backlog milestone Nov 27, 2023
@yonzhan yonzhan added Azure CLI Team The command of the issue is owned by Azure CLI team feature-request and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team feature-request
Projects
None yet
Development

No branches or pull requests

2 participants