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

'utf-8' codec can't encode characters in position 1-2: surrogates not allowed during az storage blob upload-batch #45

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

Comments

@bebound
Copy link
Owner

bebound commented Feb 27, 2023

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Related command

Describe the bug

i get this error using az cli v 2.45

To Reproduce

az storage blob upload-batch --account-name myname --account-key "0LhAHma/XyZ4ZGp1dSBMMHVLNIia0TlG2lHH3r7M07iB7SruSsHa0+QX9jIEm6gLq9vuNu5Wl+hg+AStZOU20A==" --destination ‘$web’ --source ./

The command failed with an unexpected error. Here is the traceback:
'utf-8' codec can't encode characters in position 1-2: surrogates not allowed
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 718, in _run_job
    return cmd_copy.exception_handler(ex)
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/storage/__init__.py", line 411, in new_handler
    first(ex)
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/storage/__init__.py", line 411, in new_handler
    first(ex)
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/storage/_exception_handler.py", line 17, in file_related_exception_handler
    raise ex
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/storage/operations/blob.py", line 523, in storage_blob_upload_batch
    blob_client = client.get_blob_client(container=destination_container_name,
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/multiapi/storagev2/blob/v2021_06_08/_blob_service_client.py", line 735, in get_blob_client
    return BlobClient( # type: ignore
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/multiapi/storagev2/blob/v2021_06_08/_blob_client.py", line 182, in __init__
    self._client = AzureBlobStorage(self.url, base_url=self.url, pipeline=self._pipeline)
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/multiapi/storagev2/blob/v2021_06_08/_shared/base_client.py", line 132, in url
    return self._format_url(self._hosts[self._location_mode])
  File "/usr/local/Cellar/azure-cli/2.45.0/libexec/lib/python3.10/site-packages/azure/multiapi/storagev2/blob/v2021_06_08/_blob_client.py", line 188, in _format_url
    container_name = container_name.encode('UTF-8')
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 1-2: surrogates not allowed

Expected behavior

no errors

Environment summary

sw_vers
ProductName: macOS
ProductVersion: 11.7.1
BuildVersion: 20G918

az --version
azure-cli 2.45.0

core 2.45.0
telemetry 1.0.8

Extensions:
resource-graph 2.1.0
application-insights 0.1.16

Dependencies:
msal 1.20.0
azure-mgmt-resource 21.1.0b1

Python location '/usr/local/Cellar/azure-cli/2.45.0/libexec/bin/python'
Extensions directory '/Users/cody/.azure/cliextensions'
Python (Darwin) 3.10.9 (main, Dec 15 2022, 18:20:40) [Clang 13.0.0 (clang-1300.0.29.30)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

Edit: resolved by regenerating key and retyping out command, explicitly making sure $ is escaped --destination "\$web"

Copy from https://github.com/Azure/azure-cli/issues/25384

@similar-bot-test
Copy link

Find similar issue https://github.com/Azure/azure-cli/issues/17868.

Issue title Unable to download Blob on Mac OS UTF-8
Create time 2021-04-26
Comment number 3

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

No branches or pull requests

1 participant