Skip to content

Conversation

@nancyc12
Copy link
Contributor

@nancyc12 nancyc12 commented Dec 31, 2025

This PR fixes UTF-8 decoding error when processing serial logs containing non-UTF-8 bytes (like 0xff).

Description

PR #666 (Logging Redesign) introduced the write_from_file() method without the errors="ignore" parameter that the previous code used when reading serial logs.
Added encoding="utf-8", errors="ignore" to restore the exact previous behavior.

Resolved issues

[25-12-30 07:58:08]    INFO: (job.py:129)| Running setup_command: tf-setup
[25-12-30 07:58:26]    INFO: (job.py:129)| Running provision_command: tf-provision
[25-12-30 08:11:09]   ERROR: (agent.py:415)| 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Traceback (most recent call last):
  File "/srv/testflinger-venv/lib/python3.10/site-packages/testflinger_agent/agent.py", line 377, in process_jobs
    exit_code, exit_event, exit_reason = job.run_test_phase(
  File "/srv/testflinger-venv/lib/python3.10/site-packages/testflinger_agent/job.py", line 194, in run_test_phase
    self.serial_output_handler.write_from_file(serial_log)
  File "/srv/testflinger-venv/lib/python3.10/site-packages/testflinger_agent/handlers.py", line 198, in write_from_file
    data = log.read(chunk_size)
  File "/usr/lib/python3.10/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
[25-12-30 08:11:10]    INFO: (job.py:129)| Running cleanup_command: tf-cleanup

Documentation

Web service API changes

Tests

@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.38%. Comparing base (accf330) to head (93c6454).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #856   +/-   ##
=======================================
  Coverage   71.38%   71.38%           
=======================================
  Files         108      108           
  Lines        9674     9674           
  Branches      860      860           
=======================================
  Hits         6906     6906           
  Misses       2595     2595           
  Partials      173      173           
Flag Coverage Δ *Carryforward flag
agent 72.85% <100.00%> (ø)
cli 87.90% <ø> (ø) Carriedforward from accf330
device 55.21% <ø> (ø) Carriedforward from accf330
server 87.71% <ø> (ø) Carriedforward from accf330

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
Agent 72.85% <100.00%> (ø)
CLI 87.90% <ø> (ø)
Common ∅ <ø> (∅)
Device Connectors 55.21% <ø> (ø)
Server 87.71% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@kevinyehk kevinyehk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

@nancyc12 nancyc12 merged commit 563acb6 into main Dec 31, 2025
14 checks passed
@nancyc12 nancyc12 deleted the fix-agent-write-non-UTF-8 branch December 31, 2025 02:22
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

Successfully merging this pull request may close these issues.

3 participants