Enhancement: Add Support for HTTP-Based Failure Notifications #4

Open
opened 2025-04-11 13:07:56 -04:00 by nick · 0 comments
Owner

Description

Add support to 753 Data Sync for sending a push-style HTTP POST request when a task fails. This feature will allow the script to integrate with external automation tools (e.g., Microsoft Power Automate) and send real-time failure notifications (such as email alerts).


Proposed Behavior

When any part of the sync task fails, the script should:

  • Check for an environment variable to determine if notifications are enabled.
  • If enabled, send an HTTP POST to a target URL (also defined via environment variable) with structured failure details.

New Environment Variables

Variable Name Description
SYNC_NOTIFY_ON_FAILURE Optional. If set to true, the script will send a notification when a task fails.
SYNC_FAILURE_NOTIFY_URL Optional. The URL that receives the HTTP POST payload upon failure.

Payload Example

On failure, the script will send a JSON payload like the following:

{
  "task": "upload_to_s3",
  "error": "AccessDenied: Cannot write to S3 bucket",
  "timestamp": "2025-04-11T19:15:00Z"
}

Benefits

  • Enables better visibility into failures.
  • Easy integration with services like:
    • Microsoft Power Automate (email/push notifications).
    • Slack webhooks.
    • Custom monitoring endpoints.
  • Non-intrusive: feature only activates if environment variables are set.

Implementation Notes

  • Use Python’s requests module to perform the HTTP POST.
  • Ensure the failure notification step is wrapped in a try/except block so it doesn't interrupt error handling or logging logic.
  • Timestamp should be in ISO 8601 format using datetime.utcnow().isoformat().
#### **Description** Add support to **753 Data Sync** for sending a push-style HTTP POST request when a task fails. This feature will allow the script to integrate with external automation tools (e.g., Microsoft Power Automate) and send real-time failure notifications (such as email alerts). --- #### **Proposed Behavior** When any part of the sync task fails, the script should: - Check for an environment variable to determine if notifications are enabled. - If enabled, send an HTTP POST to a target URL (also defined via environment variable) with structured failure details. --- #### **New Environment Variables** | Variable Name | Description | |---------------|-------------| | `SYNC_NOTIFY_ON_FAILURE` | Optional. If set to `true`, the script will send a notification when a task fails. | | `SYNC_FAILURE_NOTIFY_URL` | Optional. The URL that receives the HTTP POST payload upon failure. | --- #### **Payload Example** On failure, the script will send a JSON payload like the following: ```json { "task": "upload_to_s3", "error": "AccessDenied: Cannot write to S3 bucket", "timestamp": "2025-04-11T19:15:00Z" } ``` --- #### **Benefits** - Enables better visibility into failures. - Easy integration with services like: - Microsoft Power Automate (email/push notifications). - Slack webhooks. - Custom monitoring endpoints. - Non-intrusive: feature only activates if environment variables are set. --- #### **Implementation Notes** - Use Python’s `requests` module to perform the HTTP POST. - Ensure the failure notification step is wrapped in a `try/except` block so it doesn't interrupt error handling or logging logic. - Timestamp should be in ISO 8601 format using `datetime.utcnow().isoformat()`.
nick added the
enhancement
label 2025-04-11 13:07:56 -04:00
nick self-assigned this 2025-04-15 09:52:29 -04:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: nick/753-Data-Sync#4
No description provided.