← Back to issue list

Bad handling of non-utf8 text in _PipeReaderThread

View original Github issue

Metadata

Project
craft-cli
Number
#221
Type
issue
State
closed
Author
tigarmo
Labels
—
Created
Updated
Closed

Current evaluation

Fixed invalid UTF-8 handling in _PipeReaderThread by decoding subprocess bytes with replacement; PR #222 was merged as commit 9e017d4.

Resolution: closed resolved

Reason: PR #222 resolved the crash by using decode("utf8", errors="replace") and was merged in commit 9e017d4.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Bug Description the naked `decode("utf-8")` in [_write()](https://github.com/canonical/craft-cli/blob/main/craft_cli/messages.py#L243C39-L243C54) breaks when the incoming text isn't valid utf-8. ### To Reproduce See related issue in Snapcraft: https://github.com/snapcore/snapcraft/issues/4515 ### part yaml _No response_ ### Relevant log output ```shell :: [build HPX] el/helpcontent2/source/text/simpress/guide :: Entity: line 1: parser error : Opening and ending tag mismatch: switchinline line 1 and root Exception in thread Thread-45: Traceback (most recent call last): File "/snap/snapcraft/10279/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/snap/snapcraft/10279/lib/python3.10/site-packages/craft_cli/messages.py", line 285, in run self._run_posix() File "/snap/snapcraft/10279/lib/python3.10/site-packages/craft_cli/messages.py", line 257, in _run_posix self._write(data) File "/snap/snapcraft/10279/lib/python3.10/site-packages/craft_cli/messages.py", line 242, in _write unicode_line = useful_line.decode("utf8") UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbc in position 0: invalid start byte ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed invalid UTF-8 handling in _PipeReaderThread by decoding subprocess bytes with replacement; PR #222 was merged as commit 9e017d4.
stealth/space-bunny-alpha — closed resolved Invalid UTF-8 from subprocesses no longer crashes _PipeReaderThread. Merged PR #222 replaced the strict decoder with error handling and was verified in Snapcraft.
qwen/qwen3.6-35b-a3b — — Closed without comments or documented resolution. The UTF-8 decoding error in _PipeReaderThread remains unaddressed.
qwen/qwen3.6-35b-a3b — — Closed without resolution or linked pull request. The UnicodeDecodeError triggered by unhandled non-UTF-8 input in _PipeReaderThread remains unaddressed.
qwen/qwen3.6-35b-a3b — — Closed without resolution. A UnicodeDecodeError in craft_cli when processing non-UTF-8 output was reported, but no patch or follow-up was provided.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-cli#222 (confidence 100%)

    Merged fix for decoding invalid UTF-8 from subprocesses.

  • Related To: snapcore/snapcraft#4515 (confidence 100%)

    Original report cited this Snapcraft issue as the reproduction case.

Related issues

No related issues found above the similarity threshold.