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

Installation of extension(s) is not working due to parsing error of extensionCommandTree.json: json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0) #28321

Closed
Hi-Fi opened this issue Feb 7, 2024 · 24 comments
Labels
ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Milestone

Comments

@Hi-Fi
Copy link

Hi-Fi commented Feb 7, 2024

Describe the bug

When trying to install extensions, just getting error

The command failed with an unexpected error. Here is the traceback:
Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

This happens both locally (using e.g. docker run -it --rm mcr.microsoft.com/azure-cli) and at Azure DevOps.

Related command

az account subscription list (even without logging in)

Errors

The command failed with an unexpected error. Here is the traceback:
Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

Issue script & Debug output

aba60738e9d4:/# az account subscription list
The command failed with an unexpected error. Here is the traceback:
Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/__init__.py", line 335, in loads
    raise JSONDecodeError("Unexpected UTF-8 BOM (decode using utf-8-sig)",
json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 589, in execute
    parsed_args = self.parser.parse_args(args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/knack/parser.py", line 261, in parse_args
    return super().parse_args(args)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/argparse.py", line 1869, in parse_args
    args, argv = self.parse_known_args(args, namespace)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/azure/cli/core/parser.py", line 281, in parse_known_args
    self._namespace, self._raw_arguments = super().parse_known_args(args=args, namespace=namespace)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/argparse.py", line 1902, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/argparse.py", line 2117, in _parse_known_args
    stop_index = consume_positionals(start_index)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/argparse.py", line 2073, in consume_positionals
    take_action(action, args)
  File "/usr/local/lib/python3.11/argparse.py", line 1978, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/local/lib/python3.11/argparse.py", line 1241, in __call__
    subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/azure/cli/core/parser.py", line 281, in parse_known_args
    self._namespace, self._raw_arguments = super().parse_known_args(args=args, namespace=namespace)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/argparse.py", line 1902, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/argparse.py", line 2117, in _parse_known_args
    stop_index = consume_positionals(start_index)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/argparse.py", line 2073, in consume_positionals
    take_action(action, args)
  File "/usr/local/lib/python3.11/argparse.py", line 1962, in take_action
    argument_values = self._get_values(action, argument_strings)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/azure/cli/core/parser.py", line 272, in _get_values
    value = super(AzCliCommandParser, self)._get_values(action, arg_strings)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/argparse.py", line 2506, in _get_values
    self._check_value(action, value[0])
  File "/usr/local/lib/python3.11/site-packages/azure/cli/core/parser.py", line 300, in _check_value
    use_dynamic_install = try_install_extension(self, args)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/azure/cli/core/extension/dynamic_install.py", line 119, in try_install_extension
    _check_value_in_extensions(cli_ctx, parser, args, use_dynamic_install == 'yes_without_prompt')
  File "/usr/local/lib/python3.11/site-packages/azure/cli/core/extension/dynamic_install.py", line 150, in _check_value_in_extensions
    ext_name = _search_in_extension_commands(cli_ctx, command_str, allow_prefix_match=allow_prefix_match)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/azure/cli/core/extension/dynamic_install.py", line 87, in _search_in_extension_commands
    cmd_chain = _get_extension_command_tree(cli_ctx)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/azure/cli/core/extension/dynamic_install.py", line 38, in _get_extension_command_tree
    EXT_CMD_TREE.data = response.json()
                        ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

Expected behavior

Extension installed fine and command that was asked done.

Environment Summary

{
  "azure-cli": "2.57.0",
  "azure-cli-core": "2.57.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {}
}

Additional context

No response

@Hi-Fi Hi-Fi added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Feb 7, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. Auto-Assign Auto assign by bot ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group labels Feb 7, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Azure CLI Team The command of the issue is owned by Azure CLI team label Feb 7, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Feb 7, 2024

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

@microsoft-github-policy-service microsoft-github-policy-service bot added the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Feb 7, 2024
@FileJunkie
Copy link

az aks pod-identity add is also not working.

@mdrakiburrahman
Copy link

mdrakiburrahman commented Feb 7, 2024

We're also hitting this, our automation pipelines are all blocked. This is a new regression caused last night in Azure CLI, things were working fine last night for the same pipeline:

image

@felazuris
Copy link

az devops configure is failing for us

@yonzhan yonzhan added this to the Backlog milestone Feb 7, 2024
@yonzhan yonzhan removed the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Feb 7, 2024
@MarcDenman
Copy link

We have run into this as well running az network front-door list in some of our pipelines.

@pbahnl
Copy link

pbahnl commented Feb 7, 2024

Same here for deployment pipelines using az-cli. Everything fails.

@syneex
Copy link

syneex commented Feb 7, 2024

az devops configure is also failing for us and we are blocked because of that.

@josh-yates
Copy link

josh-yates commented Feb 7, 2024

It seems to be happening when az doesn't recognise a command and is looking for an extension, as it happens for eg. az abc123. Manually installing extensions using az extension add --name {extension} appears to be a workaround.

@jiasli jiasli changed the title Installation of extension(s) is not working due to parsing error of extensionCommandTree.json Installation of extension(s) is not working due to parsing error of extensionCommandTree.json: json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0) Feb 7, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Feb 7, 2024

We are looking into this and will reply here after we figure out.

@balcsida
Copy link

balcsida commented Feb 7, 2024

We've experienced this issue on our side and running az account help --debug indicates that it indeed fails on https://azurecliextensionsync.blob.core.windows.net/cmd-index/extensionCommandTree.json

extensionCommandTree.json: Unicode text, UTF-8 (with BOM) text, with very long lines (65533), with no line terminators

However, I suspect the CLI code is not prepared for decoding JSON files with BOM.

@Davide-DD
Copy link

Davide-DD commented Feb 7, 2024

I'm also hitting this in Github Action, using the following job:

    uses: azure/CLI@v1
    with:
      azcliversion: 2.56.0
      inlineScript: |
        export AZURE_DEVOPS_EXT_PAT="${{ secrets.AZURE_ARTIFACTS_PAT }}"
        az config set extension.use_dynamic_install=yes_without_prompt
        az artifacts universal download --organization "$ORGANIZATION" --project "7ac49839-f0e7-4bcd-a5c3-6b465a2217e9" --scope project --feed "Common" --name "$NAME" --version "${{env.REQUESTED_FRONTEND_VERSION}}" --path $GITHUB_WORKSPACE/wwwroot

The same job was working fine until one hour before, then it just broke. The key "runs-on" is set to "ubuntu-latest".

@robinsmidsrod
Copy link

I use the SSH extension in a pipeline, and explicitly doing az extension add --name ssh avoided the above-mentioned issue.

@RenanCarlosPereira
Copy link

RenanCarlosPereira commented Feb 7, 2024

also happening here:
az monitor app-insights component show --app app-name -g your-resource-group

The command failed with an unexpected error. Here is the traceback:
Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)
Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/models.py", line 971, in json
File "json_init_.py", line 335, in loads
json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

@akku16
Copy link

akku16 commented Feb 7, 2024

We have also started facing the same issue since today morning for all az commands.
The version is azure-cli : 2.50.0

@malsey
Copy link

malsey commented Feb 7, 2024

It seems to be happening when az doesn't recognise a command and is looking for an extension, as it happens for eg. az abc123. Manually installing extensions using az extension add --name {extension} appears to be a workaround.

This workaround works fine

@bondido
Copy link

bondido commented Feb 7, 2024

I'm also hitting this in Github Action, using the following job:

    uses: azure/CLI@v1
    with:
      azcliversion: 2.56.0
      inlineScript: |
        export AZURE_DEVOPS_EXT_PAT="${{ secrets.AZURE_ARTIFACTS_PAT }}"
        az config set extension.use_dynamic_install=yes_without_prompt
        az artifacts universal download --organization "$ORGANIZATION" --project "7ac49839-f0e7-4bcd-a5c3-6b465a2217e9" --scope project --feed "Common" --name "$NAME" --version "${{env.REQUESTED_FRONTEND_VERSION}}" --path $GITHUB_WORKSPACE/wwwroot

The same job was working fine until one hour before, then it just broke. The key "runs-on" is set to "ubuntu-latest".

In our case, we've also get rid of
az config set extension.use_dynamic_install=yes_without_prompt
as it could try (and fail) to install some extensions that we're not even aware of.

We've changed it to:
az config set extension.use_dynamic_install=no

and installed all required extensions with
az extension add --name ...

@TNEL
Copy link

TNEL commented Feb 7, 2024

i have some issue running

echo '3....' | az devops login --org https://dev.azure.com/org

ERROR: The command failed with an unexpected error. Here is the traceback: ERROR: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0) Traceback (most recent call last): File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 588, in execute File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/parser.py", line 261, in parse_args File "argparse.py", line 1826, in parse_args File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 281, in parse_known_args File "argparse.py", line 1859, in parse_known_args File "argparse.py", line 2054, in _parse_known_args File "argparse.py", line 2031, in consume_positionals File "argparse.py", line 1920, in take_action File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 272, in _get_values File "argparse.py", line 2465, in _get_values File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 300, in _check_value File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/extension/dynamic_install.py", line 119, in try_install_extension File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/extension/dynamic_install.py", line 143, in _check_value_in_extensions File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/extension/dynamic_install.py", line 87, in _search_in_extension_commands File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/extension/dynamic_install.py", line 38, in _get_extension_command_tree File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/models.py", line 910, in json File "json\__init__.py", line 335, in loads json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0) To check existing issues, please visit: https://github.com/Azure/azure-cli/issues To open a new issue, please run az feedback``

@MichalJes
Copy link

Same problem while running az monitor app-insights component create

@jiasli
Copy link
Member

jiasli commented Feb 7, 2024

ℹ️ Official Announcement

We have identified the root cause to be the incorrect metadata of the Command Tree file:

azmirror_endpoint else 'https://aka.ms/azExtCmdTree'

We have already fixed it and dynamic installation should now work as expected. Please retry the commands.

Thanks for reporting this issue and apologize for the inconvenience caused.

@jiasli jiasli closed this as completed Feb 7, 2024
@jiasli jiasli reopened this Feb 7, 2024
@odegroot
Copy link

odegroot commented Feb 7, 2024

Confirmed, the error is now gone for me, without changing anything on my side.

@Davide-DD
Copy link

Everything seems okay now, just ran the same pipeline and it is executing without any problem

@grixxie
Copy link

grixxie commented Feb 7, 2024

Confirmed this has solved my issues without changing anything on my side, thank you!

@MikeLanglois
Copy link

Issue has been resolved thanks!

@jsntcy
Copy link
Member

jsntcy commented Feb 8, 2024

Close this as it has been resolved.

@jsntcy jsntcy closed this as completed Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

Successfully merging a pull request may close this issue.