@@ -309,17 +309,20 @@ def _check_confidence_alerts(
309309 )
310310 return
311311
312+ # Safety check: ensure threshold is a valid float
313+ safe_threshold = _safe_float_conversion (threshold , 0.9 )
314+
312315 # First check if this assessment_data itself is a direct confidence assessment
313316 if "confidence" in assessment_data :
314317 confidence = _safe_float_conversion (
315318 assessment_data .get ("confidence" , 0.0 ), 0.0
316319 )
317- if confidence < threshold :
320+ if confidence < safe_threshold :
318321 alerts_list .append (
319322 {
320323 "attribute_name" : attr_name ,
321324 "confidence" : confidence ,
322- "confidence_threshold" : threshold ,
325+ "confidence_threshold" : safe_threshold ,
323326 }
324327 )
325328
@@ -329,7 +332,7 @@ def _check_confidence_alerts(
329332 confidence = _safe_float_conversion (
330333 sub_assessment .get ("confidence" , 0.0 ), 0.0
331334 )
332- if confidence < threshold :
335+ if confidence < safe_threshold :
333336 full_attr_name = (
334337 f"{ attr_name } .{ sub_attr_name } "
335338 if "." not in attr_name
@@ -339,7 +342,7 @@ def _check_confidence_alerts(
339342 {
340343 "attribute_name" : full_attr_name ,
341344 "confidence" : confidence ,
342- "confidence_threshold" : threshold ,
345+ "confidence_threshold" : safe_threshold ,
343346 }
344347 )
345348
@@ -803,8 +806,8 @@ def process_document_section(self, document: Document, section_id: str) -> Docum
803806 parsing_succeeded = False # Mark that parsing failed
804807
805808 # Get confidence thresholds
806- default_confidence_threshold = assessment_config . get (
807- "default_confidence_threshold" , 0.9
809+ default_confidence_threshold = _safe_float_conversion (
810+ assessment_config . get ( "default_confidence_threshold" , 0.9 ) , 0.9
808811 )
809812
810813 # Enhance assessment data with confidence thresholds and create confidence threshold alerts
0 commit comments