Fix TypeError in Bedesten search tools - add null safety checks
Resolves 'cannot convert undefined or null to object' error in search_bedesten_unified by adding proper null checking for response.data.emsalKararList and response.data.total fields before accessing them. - Add hasattr() and null checks for response.data fields - Provide safe defaults: empty list for emsalKararList, 0 for total - Prevents TypeError when API returns undefined/null fields - Matches null safety pattern used in other search tools
This commit is contained in:
+6
-2
@@ -1145,9 +1145,13 @@ For best results, use exact phrases with quotes for legal terms."""),
|
|||||||
"error": "No data returned from Bedesten API"
|
"error": "No data returned from Bedesten API"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add null safety checks for response.data fields
|
||||||
|
emsal_karar_list = response.data.emsalKararList if hasattr(response.data, 'emsalKararList') and response.data.emsalKararList is not None else []
|
||||||
|
total_records = response.data.total if hasattr(response.data, 'total') and response.data.total is not None else 0
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"decisions": [d.model_dump() for d in response.data.emsalKararList],
|
"decisions": [d.model_dump() for d in emsal_karar_list],
|
||||||
"total_records": response.data.total,
|
"total_records": total_records,
|
||||||
"requested_page": pageNumber,
|
"requested_page": pageNumber,
|
||||||
"page_size": pageSize,
|
"page_size": pageSize,
|
||||||
"searched_courts": court_types
|
"searched_courts": court_types
|
||||||
|
|||||||
Reference in New Issue
Block a user