Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

email: update cc list to enable multiple recipients #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

peluse
Copy link

@peluse peluse commented Oct 15, 2024

Actually, I was getting an error with just one email. Further below From my change on this LOC:

for to in to_list + cc_list:

I was getting an error about concatenating a list and a string. The to_list Was clearly a list based on how it was processed just above the for loop.

The cc_list printed its type as a list but it looked like a string logging it.

Either way, single or multiple entry cc in the config file, this patch works.

Actually, I was getting an error with just one email.  Further below
From my change on this LOC:

	for to in to_list + cc_list:

I was getting an error about concatenating a list and a string.  The to_list
Was clearly a list based on how it was processed just above the for loop.

The cc_list printed its type as a list but it looked like a string logging it.

Either way, single or multiple entry cc in the config file, this patch works.

Signed-off-by: Paul Luse <[email protected]>
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@chantra chantra requested review from danobi and theihor October 16, 2024 18:48
@chantra
Copy link
Contributor

chantra commented Oct 16, 2024

Thanks @peluse .

Are you passing a list to the email's cc entry? Or a comma-separated list of emails.

The former is expected and looking at your patch, I feel we should rather raise in


if either isinstance(smtp_to, list) or isinstance(smtp_cc, list) is False.

so the message is clear has to why this is failing, and we don't have to deal with a mix of list or comma-separated list in the rest of the code.

@danobi
Copy link

danobi commented Oct 16, 2024

Yeah for reference the email config should look something like this:

  "email": {
    "host": <REDACTED>
    "port": <REDACTED>
    "user": "bot-bpf-ci",
    "from": "[email protected]",
    "cc": [
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]"
    ],
    "pass": <REDACTED>
    "http_proxy": <REDACTED>
    "submitter_allowlist": [
      ".*"
    ],
    "ignore_allowlist": false
  },

I'd check that you're passing the right json thingy into "cc".

We should probably follow up with better documentation if we don't have that already.

@chantra
Copy link
Contributor

chantra commented Oct 16, 2024

We should probably follow up with better documentation if we don't have that already.

Totally. I was mentioning to @theihor to update the documentation has he goes through setting his own testing repository.

Tests are currently failing for some other reasons (a revert should make it to main soon), but this got caught in our internal CI with:

test_email_submitter_not_in_allowlist (kernel.kernel_patches_daemon.oss.tests.test_branch_worker.TestEmailNotification) ... ERROR

======================================================================
ERROR: test_email_submitter_not_in_allowlist (kernel.kernel_patches_daemon.oss.tests.test_branch_worker.TestEmailNotification)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/path/to/repo/kernel/kernel_patches_daemon/oss/tests/__test_branch_worker__/test_branch_worker#link-tree/kernel/kernel_patches_daemon/oss/tests/test_branch_worker.py", line 1332, in test_email_submitter_not_in_allowlist
    cmd, email = build_email(
  File "/path/to/repo/kernel/kernel_patches_daemon/oss/tests/__test_branch_worker__/test_branch_worker#link-tree/kernel_patches_daemon/branch_worker.py", line 291, in build_email
    cc_list = copy.copy(config.smtp_cc).split(",")
AttributeError: 'list' object has no attribute 'split'

----------------------------------------------------------------------
Ran 1 test in 0.002s

FAILED (errors=1)

AttributeError: 'list' object has no attribute 'split'
  File "/path/to/python/lib/python3.10/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/path/to/python/lib/python3.10/unittest/case.py", line 591, in run
    self._callTestMethod(testMethod)
  File "/path/to/python/lib/python3.10/unittest/case.py", line 549, in _callTestMethod
    method()
  File "/path/to/repo/kernel/kernel_patches_daemon/oss/tests/__test_branch_worker__/test_branch_worker#link-tree/kernel/kernel_patches_daemon/oss/tests/test_branch_worker.py", line 1332, in test_email_submitter_not_in_allowlist
    cmd, email = build_email(
  File "/path/to/repo/kernel/kernel_patches_daemon/oss/tests/__test_branch_worker__/test_branch_worker#link-tree/kernel_patches_daemon/branch_worker.py", line 291, in build_email
    cc_list = copy.copy(config.smtp_cc).split(",")

@chantra
Copy link
Contributor

chantra commented Oct 16, 2024

The type checker (which I don't think we run here either, and probably should follow up) caught it too:

Test returned with non-zero exit code
stdout:

stderr:
Found type errors!
kernel/kernel_patches_daemon/oss/kernel_patches_daemon/branch_worker.py:291:14 Undefined attribute [16]: `typing.List` has no attribute `split`.

@peluse
Copy link
Author

peluse commented Oct 28, 2024

thanks guys! sorry was off for the last week. I was not using the format mentioned above and didn't see any examples so I was just putting one email address in there in quotes and it didn't work. Looking at what you suggest surely looks like it will work. I will test it out very soon and close this PR when it works ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants