Skip to content

RHCLOUD-49576: Add Lightwell instant email template for java_remediated - #4794

Merged
g-duval merged 3 commits into
RedHatInsights:masterfrom
g-duval:RHCLOUD-49576-lightwell-email-template
Aug 5, 2026
Merged

RHCLOUD-49576: Add Lightwell instant email template for java_remediated#4794
g-duval merged 3 commits into
RedHatInsights:masterfrom
g-duval:RHCLOUD-49576-lightwell-email-template

Conversation

@g-duval

@g-duval g-duval commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the Qute instant email template for the Lightwell bundle's java_remediated event type, per RHCLOUD-49576 (part of the RHCLOUD-49566 epic).

  • Adds lightwellDefaultEmailBody.html, rendering the list of remediated packages/releases/CVEs (with severity badges) from the event payload.
  • Adds Lightwell.java mapping class registering the template for the lightwell/lightwell bundle/app, and wires it into TemplateService.
  • Extends the shared Common/insightsEmailBody.html with a renderHeaderTitle toggle and a content-footer insertion point, needed by the Lightwell template's custom header/footer.
  • Adds TestLightwellTemplate covering: multi-package rendering, singular vs. plural wording, the full severity matrix (low/moderate/important/critical), the events-counter badge, the CTA button, and both footer variants (ignore_user_preferences true/false).

Note: the same template is used for both java_remediated and the upcoming python_remediated event type — it's mapped at the application level (Lightwell.templatesMap) rather than per-event-type, since the payload/rendering is identical for both. This mapping can be revisited if the event types diverge later.

Test plan

  • ./mvnw validate -pl :notifications-common-template (checkstyle)
  • ./mvnw test -pl :notifications-common-template -Dtest=TestLightwellTemplate (5/5 passing)

🤖 Generated with Claude Code

image

Linked Json payload is:

  {
    "version": "2.0.0",
    "bundle": "lightwell",
    "application": "lightwell",
    "event_type": "java_remediated",
    "timestamp": "2026-08-05T12:18:34.081804291",
    "org_id": "123456",
    "context": {},
    "events": [
      {
        "metadata": {},
        "payload": {
          "package_name": "org.glassfish.jaxb:codemodel",
          "package_link": "https://console.redhat.com/lightwell/packages/org.glassfish.jaxb:codemodel",
          "releases": [
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-1234.json", "cve": "CVE-2026-1234", "severity": "critical" },
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-5678.json", "cve": "CVE-2026-5678", "severity": "critical" },
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-9999.json", "cve": "CVE-2026-9999", "severity": "critical" }
              ],
              "release_names": [
                { "name": "4.0.4.rhlw003" },
                { "name": "4.0.4.rhlw004" }
              ]
            },
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-1234.json", "cve": "CVE-2026-1234", "severity": "critical" },
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-5678.json", "cve": "CVE-2026-5678", "severity": "critical" },
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-9999.json", "cve": "CVE-2026-9999", "severity": "critical" }
              ],
              "release_names": [
                { "name": "5.0.0.rhlw001" }
              ]
            },
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-1234.json", "cve": "CVE-2026-1234", "severity": "critical" },
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-5678.json", "cve": "CVE-2026-5678", "severity": "critical" },
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-9999.json", "cve": "CVE-2026-9999", "severity": "critical" }
              ],
              "release_names": [
                { "name": "5.5.5.rhlw001" }
              ]
            }
          ]
        }
      },
      {
        "metadata": {},
        "payload": {
          "package_name": "org.glassfish.jaxb:jaxb-core",
          "package_link": "https://console.redhat.com/lightwell/packages/org.glassfish.jaxb:jaxb-core",
          "releases": [
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-1111.json", "cve": "CVE-2026-1111", "severity": "important" },
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-2222.json", "cve": "CVE-2026-2222", "severity": "important" },
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-9999.json", "cve": "CVE-2026-9999", "severity": "critical" }
              ],
              "release_names": [
                { "name": "4.0.4.rhlw003" }
              ]
            }
          ]
        }
      },
      {
        "metadata": {},
        "payload": {
          "package_name": "org.glassfish.jaxb:jaxb-jxc",
          "package_link": "https://console.redhat.com/lightwell/packages/org.glassfish.jaxb:jaxb-jxc",
          "releases": [
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-2222.json", "cve": "CVE-2026-2222", "severity": "important" }
              ],
              "release_names": [
                { "name": "4.0.4.rhlw003" }
              ]
            }
          ]
        }
      },
      {
        "metadata": {},
        "payload": {
          "package_name": "org.glassfish.jaxb:jaxb-runtime",
          "package_link": "https://console.redhat.com/lightwell/packages/org.glassfish.jaxb:jaxb-runtime",
          "releases": [
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-3333.json", "cve": "CVE-2026-3333", "severity": "important" }
              ],
              "release_names": [
                { "name": "4.0.4.rhlw003" }
              ]
            }
          ]
        }
      },
      {
        "metadata": {},
        "payload": {
          "package_name": "org.glassfish.jaxb:jaxb-xjc",
          "package_link": "https://console.redhat.com/lightwell/packages/org.glassfish.jaxb:jaxb-xjc",
          "releases": [
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-4242.json", "cve": "CVE-2026-4242", "severity": "important" }
              ],
              "release_names": [
                { "name": "4.1.0.rhlw001" }
              ]
            }
          ]
        }
      },
      {
        "metadata": {},
        "payload": {
          "package_name": "org.glassfish.jaxb:txw2",
          "package_link": "https://console.redhat.com/lightwell/packages/org.glassfish.jaxb:txw2",
          "releases": [
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-4242.json", "cve": "CVE-2026-4242", "severity": "important" }
              ],
              "release_names": [
                { "name": "4.1.0.rhlw001" }
              ]
            }
          ]
        }
      },
      {
        "metadata": {},
        "payload": {
          "package_name": "org.glassfish.jaxb:txwc2",
          "package_link": "https://console.redhat.com/lightwell/packages/org.glassfish.jaxb:txwc2",
          "releases": [
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-4242.json", "cve": "CVE-2026-4242", "severity": "important" }
              ],
              "release_names": [
                { "name": "4.1.0.rhlw001" }
              ]
            }
          ]
        }
      },
      {
        "metadata": {},
        "payload": {
          "package_name": "org.glassfish.jaxb:xsom",
          "package_link": "https://console.redhat.com/lightwell/packages/org.glassfish.jaxb:xsom",
          "releases": [
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-0909.json", "cve": "CVE-2026-0909", "severity": "critical" }
              ],
              "release_names": [
                { "name": "4.0.4.rhlw003" }
              ]
            }
          ]
        }
      },
      {
        "metadata": {},
        "payload": {
          "package_name": "org.json:json",
          "package_link": "https://console.redhat.com/lightwell/packages/org.json:json",
          "releases": [
            {
              "related_cve": [
                { "url": "https://console.redhat.com/api/lightwell/cves/CVE-2026-0909.json", "cve": "CVE-2026-0909", "severity": "critical" }
              ],
              "release_names": [
                { "name": "20220320.0.0.rhlw-00002" },
                { "name": "20220320.0.0.rhlw-00001" }
              ]
            }
          ]
        }
      }
    ],
    "recipients": []
  }

Summary by CodeRabbit

  • New Features

    • Added Lightwell-branded email notifications for Java remediation events.
    • Included package, release, CVE, severity, branding, and action-link details.
    • Added support for conditional header titles and organization information.
  • Bug Fixes

    • Improved footer rendering while preserving preference and critical-message behavior.
  • Documentation

    • Documented the Lightwell template mapping and bundle identifier.
  • Tests

    • Added coverage for single and multiple packages, severity levels, links, branding, and footer behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds Lightwell email template registration, rendering, shared header and footer conditions, documentation, and Quarkus tests for package, release, CVE, severity, link, branding, and preference content.

Changes

Lightwell email rendering

Layer / File(s) Summary
Mapping and registration
common-template/src/main/java/com/redhat/cloud/notifications/qute/templates/mapping/Lightwell.java, common-template/src/main/java/com/redhat/cloud/notifications/qute/templates/TemplateService.java, docs/template-guidelines.md
Defines Lightwell identifiers, maps the Java Remediated event to the Lightwell email template, registers the mapping, and documents the lightwell bundle.
Template composition
common-template/src/main/resources/templates/email/Lightwell/lightwellDefaultEmailBody.html, common-template/src/main/resources/templates/email/Common/insightsEmailBody.html, common-template/src/main/resources/templates/email/Secure/Common/insightsEmailBody.html
Adds Lightwell branding, package, release, CVE, severity, action-link, and footer content. Shared templates conditionally render the header and expose footer content through content-footer.
Rendering validation
common-template/src/test/java/email/TestLightwellTemplate.java
Tests package and release output, CVE severities, pluralization, branding, action links, and footer preference behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TemplateService
  participant Lightwell
  participant LightwellEmailBody
  participant InsightsEmailBody
  TemplateService->>Lightwell: register templatesMap
  Lightwell->>LightwellEmailBody: resolve Java Remediated email template
  LightwellEmailBody->>InsightsEmailBody: include shared email layout
  InsightsEmailBody-->>LightwellEmailBody: render conditional header and footer
Loading

Possibly related PRs

Suggested reviewers: gwenneg

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the addition of the Lightwell instant email template for the java_remediated event.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@common-template/src/main/resources/templates/email/Lightwell/lightwellDefaultEmailBody.html`:
- Around line 72-78: Update the Lightwell footer link in
lightwellDefaultEmailBody.html to use the user-preferences notifications URL
with the environment, bundle, and application parameters. In
TestLightwellTemplate.java, extend the rendered-email assertion to verify this
destination in addition to the existing link label.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ca5d59fc-5aa8-4831-be06-8aa398d4bb85

📥 Commits

Reviewing files that changed from the base of the PR and between b7e2351 and 7075894.

📒 Files selected for processing (5)
  • common-template/src/main/java/com/redhat/cloud/notifications/qute/templates/TemplateService.java
  • common-template/src/main/java/com/redhat/cloud/notifications/qute/templates/mapping/Lightwell.java
  • common-template/src/main/resources/templates/email/Common/insightsEmailBody.html
  • common-template/src/main/resources/templates/email/Lightwell/lightwellDefaultEmailBody.html
  • common-template/src/test/java/email/TestLightwellTemplate.java

@larrymou9

Copy link
Copy Markdown
Collaborator

Performance Tests failed

PR #4794
Branch RHCLOUD-49576-lightwell-email-template
SHA 707589460e2ad59c5af594abbaa550d0be76722c
Build #108
Image tested quay.io/redhat-user-workloads/hcc-integrations-tenant/notifications/notifications-backend:on-pr-707589460e2ad59c5af594abbaa550d0be76722c

Tests run: InsightsNotificationswebhook_runner · InsightsNotificationsgw_runner · InsightsNotificationsemail_runner

📊 Performance Results

InsightsNotificationsemail_runner

Metric Result Value Min Max
notifications-engine-service.restarts.sum ✅ PASS 0.000 0.000 0.000
notifications-connector-email-service.restarts.sum ✅ PASS 0.000 0.000 0.000
SUMMARY.total_rps ❌ FAIL 13.864 13.966 14.498
SUMMARY.median_response_time ✅ PASS 11.000 10.000 12.000
POST_notifications.avg_response_time ❌ FAIL 32.198 25.972 30.650
SUMMARY.num_failures ✅ PASS 0.000 0.000 0.000
SUMMARY.fail_ratio ✅ PASS 0.000 0.000 0.000

InsightsNotificationswebhook_runner

Metric Result Value Min Max
notifications-engine-service.restarts.sum ✅ PASS 0.000 0.000 0.000
notifications-connector-webhook-service.restarts.sum ✅ PASS 0.000 0.000 0.000
results.created_at.duration_stats.mean ❌ FAIL 156.252 141.021 154.384
results.created_at.duration_stats.median ❌ FAIL 177.922 152.376 170.057
results.created_at.rps_stats.mean ✅ PASS 3.506 3.240 3.678
results.created_at.rps_stats.median ✅ PASS 3.000 2.900 3.200

InsightsNotificationsgw_runner

Metric Result Value Min Max
notifications-engine-service.restarts.sum ✅ PASS 0.000 0.000 0.000
notifications-gw-service.restarts.sum ✅ PASS 0.000 0.000 0.000
SUMMARY.total_rps ✅ PASS 14.570 14.105 14.599
SUMMARY.median_response_time ✅ PASS 10.000 10.000 12.000
POST_notifications.avg_response_time ✅ PASS 25.099 24.871 29.947
SUMMARY.num_failures ✅ PASS 0.000 0.000 0.000
SUMMARY.fail_ratio ✅ PASS 0.000 0.000 0.000

g-duval and others added 2 commits August 5, 2026 11:59
Switch CVE severity rendering to a dedicated severity field, cache the
repeated events-count lookup, sync the Secure base template with the
same header/footer override hooks, and document the new mapping class.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Move package_name/package_link from a per-release "meta" object up to
the event payload, since they're the same for every release of a given
package. Update the template loops to use explicit aliases (event,
release, releaseName, cve) instead of the shadowed default "it", and
adjust the test fixtures to match the new payload shape.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
common-template/src/main/resources/templates/email/Lightwell/lightwellDefaultEmailBody.html (1)

3-6: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add decorative alt attributes to the non-MSO severity icons.

The visible severity text already labels each icon. Add alt="" to each non-MSO <img> so assistive technology does not announce a non-descriptive image. Update the test to assert the non-MSO icon markup. The current assertions only pass because the MSO fallback images have alt text.

  • common-template/src/main/resources/templates/email/Lightwell/lightwellDefaultEmailBody.html#L3-L6: add alt="" to each severity-tag image.
  • common-template/src/test/java/email/TestLightwellTemplate.java#L126-L133: assert that each rendered non-MSO severity image has alt="".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@common-template/src/main/resources/templates/email/Lightwell/lightwellDefaultEmailBody.html`
around lines 3 - 6, The non-MSO severity icons in renderLowTag,
renderModerateTag, renderImportantTag, and renderCriticalTag need decorative alt
attributes. Add alt="" to each image, and update TestLightwellTemplate.java
lines 126-133 to assert each rendered non-MSO severity image includes alt="".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@common-template/src/main/resources/templates/email/Lightwell/lightwellDefaultEmailBody.html`:
- Around line 3-6: The non-MSO severity icons in renderLowTag,
renderModerateTag, renderImportantTag, and renderCriticalTag need decorative alt
attributes. Add alt="" to each image, and update TestLightwellTemplate.java
lines 126-133 to assert each rendered non-MSO severity image includes alt="".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6e0b87e1-13ed-4f96-be3e-e2b3e319b39f

📥 Commits

Reviewing files that changed from the base of the PR and between 7075894 and a0c06f5.

📒 Files selected for processing (4)
  • common-template/src/main/resources/templates/email/Lightwell/lightwellDefaultEmailBody.html
  • common-template/src/main/resources/templates/email/Secure/Common/insightsEmailBody.html
  • common-template/src/test/java/email/TestLightwellTemplate.java
  • docs/template-guidelines.md

@larrymou9

Copy link
Copy Markdown
Collaborator

Performance Tests failed

PR #4794
Branch RHCLOUD-49576-lightwell-email-template
SHA a0c06f5fd7278fc6158f7105d4843f469844bbd4
Build #110
Image tested quay.io/redhat-user-workloads/hcc-integrations-tenant/notifications/notifications-backend:on-pr-a0c06f5fd7278fc6158f7105d4843f469844bbd4

Tests run: InsightsNotificationswebhook_runner · InsightsNotificationsgw_runner · InsightsNotificationsemail_runner

📊 Performance Results

InsightsNotificationsemail_runner

Metric Result Value Min Max
notifications-engine-service.restarts.sum ✅ PASS 0.000 0.000 0.000
notifications-connector-email-service.restarts.sum ✅ PASS 0.000 0.000 0.000
SUMMARY.total_rps ✅ PASS 14.153 13.966 14.498
SUMMARY.median_response_time ✅ PASS 11.000 10.000 12.000
POST_notifications.avg_response_time ✅ PASS 29.201 25.972 30.650
SUMMARY.num_failures ✅ PASS 0.000 0.000 0.000
SUMMARY.fail_ratio ✅ PASS 0.000 0.000 0.000

InsightsNotificationswebhook_runner

Metric Result Value Min Max
notifications-engine-service.restarts.sum ✅ PASS 0.000 0.000 0.000
notifications-connector-webhook-service.restarts.sum ✅ PASS 0.000 0.000 0.000
results.created_at.duration_stats.mean ❌ FAIL 160.104 141.021 154.384
results.created_at.duration_stats.median ❌ FAIL 182.526 152.376 170.057
results.created_at.rps_stats.mean ✅ PASS 3.616 3.240 3.678
results.created_at.rps_stats.median ✅ PASS 2.900 2.900 3.200

InsightsNotificationsgw_runner

Metric Result Value Min Max
notifications-engine-service.restarts.sum ✅ PASS 0.000 0.000 0.000
notifications-gw-service.restarts.sum ✅ PASS 0.000 0.000 0.000
SUMMARY.total_rps ❌ FAIL 14.632 14.105 14.599
SUMMARY.median_response_time ✅ PASS 11.000 10.000 12.000
POST_notifications.avg_response_time ✅ PASS 24.957 24.871 29.947
SUMMARY.num_failures ✅ PASS 0.000 0.000 0.000
SUMMARY.fail_ratio ✅ PASS 0.000 0.000 0.000

@g-duval
g-duval requested a review from bonscji1 August 5, 2026 11:06

@bonscji1 bonscji1 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.

LGTM

@g-duval
g-duval merged commit b96b06e into RedHatInsights:master Aug 5, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants