Skip to content

Commit a7bad53

Browse files
committed
fix(cli): handle UTF-8 BOM in CSV decoding for well inventory import
- Adjust `content.decode` to use `utf-8-sig` for correct header parsing of UTF-8 files with BOM - Prevent encoding issues when processing imported files
1 parent 8e583ea commit a7bad53

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

cli/service_adapter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def well_inventory_csv(source_file: Path | str):
5050
payload = {"detail": "Empty file"}
5151
return WellInventoryResult(1, json.dumps(payload), payload["detail"], payload)
5252
try:
53-
text = content.decode("utf-8")
53+
# Accept UTF-8 CSVs saved with a BOM so the first header is parsed correctly.
54+
text = content.decode("utf-8-sig")
5455
except UnicodeDecodeError:
5556
payload = {"detail": "File encoding error"}
5657
return WellInventoryResult(1, json.dumps(payload), payload["detail"], payload)

0 commit comments

Comments
 (0)