Skip to content

Fix default mails#221

Merged
phracek merged 1 commit intomasterfrom
fix_default_mails
Mar 5, 2026
Merged

Fix default mails#221
phracek merged 1 commit intomasterfrom
fix_default_mails

Conversation

@phracek
Copy link
Member

@phracek phracek commented Mar 5, 2026

Summary by CodeRabbit

  • Chores

    • Updated test image tags to version 0.8.9 across build and deployment workflows.
  • Refactor

    • Enhanced internal test reporting system for improved reliability.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

Version tags updated from 0.8.8 to 0.8.9 across GitHub Actions workflow, Dockerfile, and Makefile. Module-level DEFAULT_MAILS global refactored to instance attribute self.default_mails in NightlyTestsReport class, with all references updated accordingly.

Changes

Cohort / File(s) Summary
Version Updates
.github/workflows/build-and-push.yml, Dockerfile.daily-tests, Makefile
Updated daily-tests image tag and build target version from 0.8.8 to 0.8.9.
Refactoring
daily_tests/daily_nightly_tests_report.py
Converted module-level DEFAULT_MAILS global to instance attribute self.default_mails in NightlyTestsReport class. All references updated to use the instance attribute for environment loading, logging, email generation, and sending.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Fix sending mail in case of success #220: Modifies mail-sending behavior in daily_tests/daily_nightly_tests_report.py, specifically in email/pastebin handling logic that works alongside the DEFAULT_MAILS refactoring.

Poem

🐰 Version bumps hop along so neat,
From 0.8.8 to 0.8.9—what a treat!
Global mails now find their place,
As instance attributes save the day with grace.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix default mails' is vague and generic, failing to clearly convey the main technical change of converting a module-level global variable to an instance attribute. Consider a more descriptive title such as 'Convert DEFAULT_MAILS global to instance attribute in NightlyTestsReport' to better communicate the primary refactoring.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_default_mails

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
Makefile (1)

10-10: Consider a single source of truth for image version.

Line 10 hardcodes a tag that is also duplicated in other files. Centralizing the version (e.g., Make variable/env-driven) reduces future mismatch risk.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 10, The Makefile currently hardcodes the image tag string
"quay.io/sclorg/upstream-daily-tests:0.8.9" which is duplicated elsewhere;
introduce a single variable (e.g., IMAGE_VERSION or DAILY_TESTS_TAG) at the top
of the Makefile and use that variable in the podman build invocation inside the
target that runs the existing command, allowing it to be overridden from the
environment; ensure other places that reference the same tag (search for the
literal "upstream-daily-tests:0.8.9") are updated to use the new variable so the
version is single-sourced.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@daily_tests/daily_nightly_tests_report.py`:
- Around line 445-447: The loop over self.available_test_case is unpacking into
(test_case, plan, _) but plan is unused (Ruff B007) and there are several noisy
print statements; change the unpacking to (test_case, _, _) or (test_case, *_ )
to acknowledge the unused element, remove or replace per-item print calls with a
single higher-level debug/info log (use the module logger at debug level) or
aggregate output outside the nested loops so the method that contains
available_test_case and the prints only emits concise logging; update references
in that method (e.g., where print("GENERATE_MAILS: ", self.data_dict),
print("GENERATE_MAILS: Available test cases: ", self.available_test_case), and
the inner per-item prints) accordingly.
- Line 194: The print statement currently outputs raw email addresses via
self.default_mails; change it to avoid exposing full addresses by logging only
the recipient count or masked addresses instead. Locate the line that prints
self.default_mails and replace it with either a count-based message (e.g.,
"Default mails count: N") or create a small mask function that transforms each
address to a non-sensitive form (e.g., keep first char of local-part and domain,
replace rest with asterisks) and log the masked list. Ensure you update the same
method/attribute that references self.default_mails so no raw addresses are
written to stdout/logs.
- Line 187: The DEFAULT_MAILS env parsing currently does self.default_mails =
os.environ["DEFAULT_MAILS"].split(",") which can leave empty or whitespace-only
entries; update the parsing for DEFAULT_MAILS (where self.default_mails is set)
to strip whitespace from each split token and filter out any empty strings so
self.default_mails contains only valid, non-empty addresses (e.g., perform
token.strip() and keep tokens with length > 0 after stripping).

---

Nitpick comments:
In `@Makefile`:
- Line 10: The Makefile currently hardcodes the image tag string
"quay.io/sclorg/upstream-daily-tests:0.8.9" which is duplicated elsewhere;
introduce a single variable (e.g., IMAGE_VERSION or DAILY_TESTS_TAG) at the top
of the Makefile and use that variable in the podman build invocation inside the
target that runs the existing command, allowing it to be overridden from the
environment; ensure other places that reference the same tag (search for the
literal "upstream-daily-tests:0.8.9") are updated to use the new variable so the
version is single-sourced.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c72702c-343f-41d9-8311-100f9ced3fb8

📥 Commits

Reviewing files that changed from the base of the PR and between 92aaf07 and 94d6fe7.

📒 Files selected for processing (4)
  • .github/workflows/build-and-push.yml
  • Dockerfile.daily-tests
  • Makefile
  • daily_tests/daily_nightly_tests_report.py

self.smtp_port = int(os.getenv("SMTP_PORT", 25))
if "DEFAULT_MAILS" in os.environ:
DEFAULT_MAILS = os.environ["DEFAULT_MAILS"].split(",")
self.default_mails = os.environ["DEFAULT_MAILS"].split(",")
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Sanitize DEFAULT_MAILS before storing recipients.

Line 187 can retain empty/whitespace entries (e.g., trailing commas), which may cause recipient validation failures later.

Proposed fix
-        if "DEFAULT_MAILS" in os.environ:
-            self.default_mails = os.environ["DEFAULT_MAILS"].split(",")
+        if "DEFAULT_MAILS" in os.environ:
+            self.default_mails = [
+                m.strip()
+                for m in os.environ["DEFAULT_MAILS"].split(",")
+                if m.strip()
+            ]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
self.default_mails = os.environ["DEFAULT_MAILS"].split(",")
if "DEFAULT_MAILS" in os.environ:
self.default_mails = [
m.strip()
for m in os.environ["DEFAULT_MAILS"].split(",")
if m.strip()
]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@daily_tests/daily_nightly_tests_report.py` at line 187, The DEFAULT_MAILS env
parsing currently does self.default_mails =
os.environ["DEFAULT_MAILS"].split(",") which can leave empty or whitespace-only
entries; update the parsing for DEFAULT_MAILS (where self.default_mails is set)
to strip whitespace from each split token and filter out any empty strings so
self.default_mails contains only valid, non-empty addresses (e.g., perform
token.strip() and keep tokens with length > 0 after stripping).

Comment on lines +445 to 447
print("GENERATE_MAILS: ", self.data_dict)
print("GENERATE_MAILS: Available test cases: ", self.available_test_case)
for test_case, plan, _ in self.available_test_case:
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix unused loop variable and reduce noisy debug output.

Line 447 has an unused plan variable (Ruff B007), and the per-item prints on Lines 452-454/461 are very chatty in nested loops.

Proposed fix
-        print("GENERATE_MAILS: ", self.data_dict)
-        print("GENERATE_MAILS: Available test cases: ", self.available_test_case)
-        for test_case, plan, _ in self.available_test_case:
+        print("GENERATE_MAILS: starting recipient aggregation")
+        for test_case, _plan, _ in self.available_test_case:
             if test_case not in self.data_dict:
                 continue
             for _, name in self.data_dict[test_case]:
                 for cont, mails in SCLORG_MAILS.items():
-                    print(
-                        f"generate_emails: Checking if container name '{name}' starts with '{cont}'"
-                    )
                     if str(Path(name).with_suffix("")) != cont:
                         continue
                     for ml in mails:
                         if ml in self.default_mails:
                             continue
                         self.default_mails.append(ml)
-        print(f"GENERATE_MAILS: Additional emails: {self.default_mails}")
+        print(f"GENERATE_MAILS: total recipients={len(self.default_mails)}")

Also applies to: 452-454, 461-461

🧰 Tools
🪛 Ruff (0.15.2)

[warning] 447-447: Loop control variable plan not used within loop body

Rename unused plan to _plan

(B007)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@daily_tests/daily_nightly_tests_report.py` around lines 445 - 447, The loop
over self.available_test_case is unpacking into (test_case, plan, _) but plan is
unused (Ruff B007) and there are several noisy print statements; change the
unpacking to (test_case, _, _) or (test_case, *_ ) to acknowledge the unused
element, remove or replace per-item print calls with a single higher-level
debug/info log (use the module logger at debug level) or aggregate output
outside the nested loops so the method that contains available_test_case and the
prints only emits concise logging; update references in that method (e.g., where
print("GENERATE_MAILS: ", self.data_dict), print("GENERATE_MAILS: Available test
cases: ", self.available_test_case), and the inner per-item prints) accordingly.

@phracek phracek merged commit b979bb9 into master Mar 5, 2026
9 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.

1 participant