Skip to content

Error handling issues in EventBridgeSchedulerHelper #5451

@Mattral

Description

@Mattral

Error handling issues in EventBridgeSchedulerHelper

Summary

There are a few small but impactful error-handling issues in
src/sagemaker/mlops/workflow/_event_bridge_client_helper.py that can lead to unexpected exceptions or reduced debuggability.
These can be fixed safely without changing public behavior or impacting other parts of the codebase.


Affected File

sagemaker-mlops/src/sagemaker/mlops/workflow/_event_bridge_client_helper.py

Issues Identified

1. delete_schedule does not handle non-existent schedules

The delete_schedule method unconditionally calls delete_schedule on the EventBridge Scheduler client.

If the schedule does not exist, AWS raises a ResourceNotFoundException, even though the docstring states:

“Deletes an EventBridge Schedule of a given pipeline if there is one.”

This results in an unexpected exception for callers.

Expected behavior
Deleting a non-existent schedule should be a no-op or gracefully handled.


2. Inconsistent and unused error-code constants

The file defines two constants:

RESOURCE_NOT_FOUND = "ResourceNotFound"
RESOURCE_NOT_FOUND_EXCEPTION = "ResourceNotFoundException"

Only RESOURCE_NOT_FOUND_EXCEPTION is used.
RESOURCE_NOT_FOUND is unused and can be safely removed to avoid confusion and improve code clarity.


3. Exception re-raise style loses traceback context

In upsert_schedule, the exception is re-raised using:

raise e

This resets the traceback and makes debugging more difficult.


Why This Matters

  • Prevents unexpected runtime failures when deleting schedules
  • Improves debuggability by preserving tracebacks
  • Cleans up unused constants for better maintainability
  • All fixes are low-risk and backward-compatible

Suggested Fix Scope

  • Catch and ignore ResourceNotFoundException in delete_schedule
  • Remove unused RESOURCE_NOT_FOUND constant
  • Replace raise e with raise to preserve traceback

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions