fix(rank): report a tracker that is not UTF-8 instead of a traceback (#639)

* fix(rank): report a tracker that is not UTF-8 instead of a traceback

A job_search_tracker.csv saved with a spreadsheet's plain "CSV" type is
written in the ANSI code page, so one accented company name raised a
UnicodeDecodeError traceback in `rank_state.py candidates` and stopped
/rank at Step 1. Exit 1 with a one-line message instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* changelog: place the #639 entry under [Unreleased]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Mads Lorentzen <madslorentzen_17@hotmail.com>
This commit is contained in:
authored and GitHub committed 2026-10-19 19:32:59 +02:00
1 parent 9b24a8a123
commit 4cbe273b56
3 files changed
+29 -5

No files matched your search

+13
View File
@@ -160,6 +160,19 @@ class Candidates(RankStateCase):
)
self.assertEqual(out["excluded_by_tracker"], int(excluded))
def test_tracker_saved_in_a_legacy_code_page_is_reported_not_a_traceback(self):
# A spreadsheet's plain "CSV" save on Windows writes cp1252, not UTF-8.
self.write_state({"a": entry()})
tracker = self.tmp / "tracker.csv"
tracker.write_bytes("date,company,role\r\n2026-08-01,Ørsted,SOC Analyst\r\n".encode("cp1252"))
proc = subprocess.run(
[sys.executable, str(TOOL), "candidates", "--state", str(self.state), "--tracker", str(tracker)],
capture_output=True, text=True, encoding="utf-8",
)
self.assertEqual(proc.returncode, 1)
self.assertIn("is not UTF-8 text - re-save it as CSV UTF-8", proc.stderr)
self.assertNotIn("Traceback", proc.stderr)
def test_focus_filters_on_title_company_and_stored_fit_notes(self):
self.write_state(
{