This is an automated email from the ASF dual-hosted git repository.

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 1ebb9379b2 GH-55269: [Archery] Pass the sender and recipient to the 
token expiration report (#55270)
1ebb9379b2 is described below

commit 1ebb9379b2f635755e773b79e88cb99852c70455
Author: nishad shabbir <[email protected]>
AuthorDate: Fri Nov 6 18:02:09 2026 +0530

    GH-55269: [Archery] Pass the sender and recipient to the token expiration 
report (#55270)
    
    archery crossbow notify-token-expiration currently fails because 
TokenExpirationEmailReport is called with a positional argument, while its 
constructor expects keyword arguments.
    
    The command also needs to pass sender_name, sender_email, and 
recipient_email to the report so that the generated email has the correct 
headers. The sibling nightly-report command already does this correctly.
    
    ## Changes
    
    Pass report, sender_name, sender_email, and recipient_email as keyword 
arguments.
    
    Add a regression test for notify-token-expiration that checks the generated 
email headers.
    
    ## Testing
    
    Confirmed the new test fails before the fix and passes afterward.
    
    Verified that the generated email contains the expected sender and 
recipient.
    
    Ran the Archery test suite. The new test passes; 26 existing failures 
remain due to missing Docker on my local machine.
    
    flake8 passes for both modified files.
    
    No real email was sent during testing.
    
    Closes #55269.
    
    ## AI disclosure
    
    AI assisted with the code and  test. I reviewed the changes and verified 
the reported behavior and test results before submitting the PR.
    * GitHub Issue: #55269
    
    Authored-by: nishad shabbir <[email protected]>
    Signed-off-by: Raúl Cumplido <[email protected]>
---
 dev/archery/archery/crossbow/cli.py                |  7 +++++-
 .../archery/crossbow/tests/test_crossbow_cli.py    | 26 ++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/dev/archery/archery/crossbow/cli.py 
b/dev/archery/archery/crossbow/cli.py
index 56c319fe7e..81a6e2d3de 100644
--- a/dev/archery/archery/crossbow/cli.py
+++ b/dev/archery/archery/crossbow/cli.py
@@ -680,7 +680,12 @@ def notify_token_expiration(obj, days, sender_name, 
sender_email,
     if not token_expiration_date:
         token_expiration_date = 'ALREADY_EXPIRED'
     report = TokenExpirationReport(token_expiration_date, days_left)
-    email_report = TokenExpirationEmailReport(report)
+    email_report = TokenExpirationEmailReport(
+        report=report,
+        sender_name=sender_name,
+        sender_email=sender_email,
+        recipient_email=recipient_email
+    )
 
     if send:
         ReportUtils.send_email(
diff --git a/dev/archery/archery/crossbow/tests/test_crossbow_cli.py 
b/dev/archery/archery/crossbow/tests/test_crossbow_cli.py
index ee9ba1ee2f..b16cb06e79 100644
--- a/dev/archery/archery/crossbow/tests/test_crossbow_cli.py
+++ b/dev/archery/archery/crossbow/tests/test_crossbow_cli.py
@@ -15,6 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from datetime import date, timedelta
+from unittest import mock
+
 from click.testing import CliRunner
 import pytest
 
@@ -41,3 +44,26 @@ def test_crossbow_submit(tmp_path):
 
     result = invoke('submit', '--no-fetch', '--no-push', '-g', 'wheel')
     assert result.exit_code == 0
+
+
+def test_crossbow_notify_token_expiration(monkeypatch):
+    # The report carries the From/To headers, so the sender and recipient
+    # options have to reach it: send_email() only passes the rendered message
+    # on to smtplib. Dropping them left this command raising before it ever
+    # built a message.
+    queue = mock.MagicMock()
+    queue.token_expiration_date.return_value = date.today() + timedelta(days=7)
+    monkeypatch.setattr('archery.crossbow.cli.Queue',
+                        mock.MagicMock(return_value=queue))
+    monkeypatch.setattr('archery.crossbow.cli.Repo', mock.MagicMock())
+
+    result = CliRunner().invoke(crossbow, [
+        'notify-token-expiration',
+        '--sender-name', 'Crossbow Reporter',
+        '--sender-email', '[email protected]',
+        '--recipient-email', '[email protected]',
+    ])
+
+    assert result.exit_code == 0, result.exception
+    assert 'From: Crossbow Reporter <[email protected]>' in result.output
+    assert 'To: [email protected]' in result.output

Reply via email to