Skip to content

Improve: add contextual logging in scheduler exception handlers #329

Description

@neuromechanist

Summary

Several scheduler exception handlers log the error but omit key context (community_id, sync_type, failure count) that would be needed for debugging production issues. The pattern of _track_failure() swallowing context in the except block is fine, but surrounding try/except blocks could do better.

Locations

File Lines Issue
scheduler.py:104 except Exception as e: Logs to _track_failure but no explicit log line with community_id
scheduler.py:146 Same pattern No direct error log with sync context
scheduler.py:220 Same pattern Missing community context in error log
scheduler.py:279 Same pattern BEP sync errors lack community_id in log

Current Pattern (deficient)

try:
    ...
except Exception as e:
    _track_failure("github", community_id, e)
    return False  # No explicit error log with community_id

Recommended Pattern

try:
    ...
except Exception as e:
    logger.error("GitHub sync failed for %s: %s", community_id, e)
    _track_failure("github", community_id, e)
    return False

Acceptance Criteria

  • All scheduler exception handlers log community_id and sync_type
  • Error messages include the underlying exception for debugging
  • No silent failures (exceptions swallowed without log output)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Priority 2: Important, fix when possibleenhancementNew feature or requestobservabilityLogging, monitoring, and debugging

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions