Skip to content

Commit 8bbbd9e

Browse files
committed
fix: remove test comments and add logging for JSON parsing errors in mapper
1 parent 5e203fe commit 8bbbd9e

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

middleware/sql_to_arc/src/middleware/sql_to_arc/main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,5 +563,3 @@ async def main() -> None:
563563
if __name__ == "__main__":
564564
multiprocessing.freeze_support()
565565
asyncio.run(main())
566-
# test unstaged
567-
# commit test

middleware/sql_to_arc/src/middleware/sql_to_arc/mapper.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Mapper module to convert database rows to ARCTRL objects."""
22

33
import json
4+
import logging
45
from datetime import datetime
56
from typing import Any, cast
67

@@ -13,6 +14,8 @@
1314
Publication,
1415
)
1516

17+
logger = logging.getLogger(__name__)
18+
1619

1720
def map_investigation(row: dict[str, Any]) -> ArcInvestigation:
1821
"""Map a database row to an ArcInvestigation object.
@@ -107,8 +110,13 @@ def map_contact(row: dict[str, Any]) -> Person:
107110
tan=r.get("uri"),
108111
)
109112
)
110-
except (json.JSONDecodeError, TypeError):
111-
# Fallback for invalid JSON or type mismatch
113+
except (json.JSONDecodeError, TypeError) as e:
114+
# Fallback for invalid JSON or type mismatch, with logging
115+
logger.warning(
116+
"Could not parse roles JSON for contact with email '%s'. Error: %s",
117+
row.get("email", "N/A"),
118+
e,
119+
)
112120
pass
113121

114122
return Person.create(

0 commit comments

Comments
 (0)