Skip to content

Fix Division by Zero Error in ClinicActivityDataService-created-by-agentic #87

@asafchen-dig

Description

@asafchen-dig

Issue Description
An ArithmeticException is occurring in the ClinicActivityDataService when calculating active logs ratio due to potential division by zero.

Current Behavior

  • The getActiveLogsRatio method performs division without checking for zero denominator
  • No input validation for null parameters
  • Lacks proper error handling and logging
  • Can throw ArithmeticException when no logs exist for a type

Root Cause
The method doesn't validate inputs or handle edge cases properly, leading to division by zero when no logs exist for a given type.

Solution
A fix has been implemented in PR that:

  1. Adds null check for type parameter
  2. Adds zero denominator check
  3. Implements proper error handling
  4. Adds comprehensive logging
  5. Returns 0.0 as default when division by zero would occur

Impact
This issue affects clinic activity reporting and could cause service disruption when calculating ratios for types with no logs.

Testing
The fix has been tested for:

  • Null input handling
  • Zero denominator cases
  • Valid ratio calculations
  • Proper logging output

Additional Notes

  • Consider adding monitoring alerts for division by zero attempts
  • Review other similar calculations for potential arithmetic exceptions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions