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

Bugfix: decoding undefined byte sequences in process streams #162

Merged
merged 2 commits into from
Nov 3, 2021

Conversation

priitlatt
Copy link
Contributor

@priitlatt priitlatt commented Nov 3, 2021

In case there are byte sequences in the invoked subprocess output that do not have unicode representation, then unexpected UnicodeDecodeErrors might occur while decoding those byte chunks. An example stacktrace is as follows:

Traceback (most recent call last):
  File "/Users/priit/.virtualenvs/cli-tools-shZ38mB-/lib/python3.7/site-packages/codemagic_cli_tools-0.9.1-py3.7.egg/codemagic/tools/_app_store_connect/actions/publish_action.py", line 88, in publish
    self._publish_application_package(altool, application_package, validate_package)
  File "/Users/priit/.virtualenvs/cli-tools-shZ38mB-/lib/python3.7/site-packages/codemagic_cli_tools-0.9.1-py3.7.egg/codemagic/tools/_app_store_connect/actions/publish_action.py", line 116, in _publish_application_package
    self._validate_artifact_with_altool(altool, application_package.path)
  File "/Users/priit/.virtualenvs/cli-tools-shZ38mB-/lib/python3.7/site-packages/codemagic_cli_tools-0.9.1-py3.7.egg/codemagic/tools/_app_store_connect/actions/publish_action.py", line 248, in _validate_artifact_with_altool
    result = altool.validate_app(artifact_path)
  File "/Users/priit/.virtualenvs/cli-tools-shZ38mB-/lib/python3.7/site-packages/codemagic_cli_tools-0.9.1-py3.7.egg/codemagic/models/altool/altool.py", line 124, in validate_app
    return self._run_command(cmd, f'Failed to validate archive at "{artifact_path}"')
  File "/Users/priit/.virtualenvs/cli-tools-shZ38mB-/lib/python3.7/site-packages/codemagic_cli_tools-0.9.1-py3.7.egg/codemagic/models/altool/altool.py", line 143, in _run_command
    stderr=subprocess.STDOUT,
  File "/Users/priit/.virtualenvs/cli-tools-shZ38mB-/lib/python3.7/site-packages/codemagic_cli_tools-0.9.1-py3.7.egg/codemagic/cli/cli_app.py", line 430, in execute
    ).execute(**execute_kwargs)
  File "/Users/priit/.virtualenvs/cli-tools-shZ38mB-/lib/python3.7/site-packages/codemagic_cli_tools-0.9.1-py3.7.egg/codemagic/cli/cli_process.py", line 92, in execute
    self._handle_streams(self._buffer_size)
  File "/Users/priit/.virtualenvs/cli-tools-shZ38mB-/lib/python3.7/site-packages/codemagic_cli_tools-0.9.1-py3.7.egg/codemagic/cli/cli_process.py", line 72, in _handle_streams
    self._stdout += self._stdout_stream.process_buffer(buffer_size, self._print_streams)
  File "/Users/priit/.virtualenvs/cli-tools-shZ38mB-/lib/python3.7/site-packages/codemagic_cli_tools-0.9.1-py3.7.egg/codemagic/cli/cli_process_stream.py", line 58, in process_buffer
    chunk = bytes_chunk.decode(encoding='utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 8191: unexpected end of data

Result of this error is that the action execution will fail with unexpected error.

@priitlatt priitlatt added the bug Something isn't working label Nov 3, 2021
@priitlatt priitlatt merged commit 5c6e7e9 into master Nov 3, 2021
@priitlatt priitlatt deleted the bugfix/handle-broken-byte-sequences-in-buffer branch November 3, 2021 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants