Skip to content

Custom webhook notification bodies under 3 lines get replaced with "blank body" warning - #616

Merged
TheWitness merged 2 commits into
mainfrom
issue-611
Aug 4, 2026
Merged

Custom webhook notification bodies under 3 lines get replaced with "blank body" warning#616
TheWitness merged 2 commits into
mainfrom
issue-611

Conversation

@cigamit

@cigamit cigamit commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Resolves #611

@cigamit
cigamit requested a review from TheWitness August 4, 2026 15:44
@cigamit cigamit self-assigned this Aug 4, 2026
Copilot AI lite review requested due to automatic review settings August 4, 2026 15:44
@cigamit cigamit added the bug Something isn't working label Aug 4, 2026
TheWitness
TheWitness previously approved these changes Aug 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression in JobNotificationMixin.build_notification_message() where short (e.g., single-line) custom webhook bodies could be incorrectly replaced with a “blank body” warning, preventing compact JSON payloads from reaching webhook receivers.

Changes:

  • Relaxes the “blank body” detection logic from “≤ 2 lines” to “empty-only” (< 1 line after stripping).
  • Preserves short, valid rendered bodies (notably for webhook notifications) that previously got overwritten.
Suppressed comments (1)

awx/main/models/notifications.py:498

  • This change alters how rendered notification bodies are validated, but there doesn’t appear to be a test that asserts short (1–2 line) webhook bodies are preserved (the reported regression in #611). Adding a regression test (e.g., creating a Job + webhook NotificationTemplate with a 1-line JSON body template and asserting build_notification_message returns it unchanged) would prevent this from reoccurring.
        if len(body.strip().splitlines()) < 1:

Comment thread awx/main/models/notifications.py Outdated
Copilot AI review requested due to automatic review settings August 4, 2026 15:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (3)

awx/main/models/notifications.py:503

  • The user-facing warning message has a grammatical error: "return" should be "returned".
                [
                    "The template rendering return a blank body.",
                    "Please check the template.",

awx/main/models/notifications.py:498

  • The blank-body check can be simplified and made clearer. len(body.strip().splitlines()) < 1 is equivalent to checking whether the rendered body is empty/whitespace-only, and the splitlines() work is unnecessary.
        if len(body.strip().splitlines()) < 1:

awx/main/models/notifications.py:498

  • This change affects how custom notification bodies are handled (short webhook payloads should no longer be replaced). There doesn't appear to be test coverage asserting that build_notification_message() preserves a single-line custom body and only substitutes the warning for empty/whitespace-only bodies.
        # Only replace the body when the template renders to nothing
        # (empty or whitespace-only). Short single-line bodies, such as a
        # compact JSON webhook payload, must be passed through unchanged.

        if len(body.strip().splitlines()) < 1:

@TheWitness
TheWitness merged commit 4ed44f9 into main Aug 4, 2026
1 check passed
@TheWitness
TheWitness deleted the issue-611 branch August 4, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

Custom webhook notification bodies under 3 lines get replaced with "blank body" warning

3 participants