[email tool] Missing sender_address in SendEmailTool leads to Pydantic validation error #917

Closed
opened 2026-02-16 10:21:00 -05:00 by yindo · 1 comment
Owner

Originally created by @kejoe-zhang on GitHub (Jan 6, 2026).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues Dify issues & Dify Official Plugins, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

latest

Plugin version

0.0.7

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

When using the email sending tool (e.g., send_mail_batch.py), a ValidationError is raised because the sender_address field is not provided to SendEmailToolParameters, even though it's a required field.
And I found that the email-related code is inconsistent with the code of the difypkg plugin, which prevents me from submitting a PR.

✔️ Error log

An error occurred in the plugin, please contact the author of langgenius/email/email for help, error type: ValidationError, error details: 1 validation error for SendEmailToolParameters
sender_address
Field required [type=missing, input_value={'smtp_server': 'qa-smtp....], 'bcc_recipients': []}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.8/v/missing

Originally created by @kejoe-zhang on GitHub (Jan 6, 2026). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version latest ### Plugin version 0.0.7 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce When using the email sending tool (e.g., `send_mail_batch.py`), a `ValidationError` is raised because the `sender_address` field is not provided to `SendEmailToolParameters`, even though it's a required field. And I found that the email-related code is inconsistent with the code of the difypkg plugin, which prevents me from submitting a PR. ### ✔️ Error log An error occurred in the plugin, please contact the author of langgenius/email/email for help, error type: ValidationError, error details: 1 validation error for SendEmailToolParameters sender_address Field required [type=missing, input_value={'smtp_server': 'qa-smtp....], 'bcc_recipients': []}, input_type=dict] For further information visit https://errors.pydantic.dev/2.8/v/missing
yindo added the bug label 2026-02-16 10:21:00 -05:00
yindo closed this issue 2026-02-16 10:21:00 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 6, 2026):

This error happens because the SendEmailToolParameters model requires a sender_address field, but send_mail_batch.py only provides email_account, not sender_address. This mismatch triggers the Pydantic ValidationError you’re seeing. The issue is confirmed in recent reports and is due to send_mail_batch.py not using sender_address from credentials, unlike send_mail.py, which does this correctly. The recommended fix is to update send_mail_batch.py to fetch sender_address from credentials (falling back to email_account if missing) and pass it to SendEmailToolParameters, matching the logic in send_mail.py. You can find more details and the suggested code change in issue #838 and issue #1085.

As a temporary workaround, you can patch your local send_mail_batch.py by adding:

sender_address = self.runtime.credentials.get("sender_address", sender)
# ...
send_email_params = SendEmailToolParameters(
    smtp_server=smtp_server,
    smtp_port=smtp_port,
    email_account=sender,
    email_password=password,
    sender_address=sender_address,
    # ... other fields ...
)

This should resolve the validation error until an official fix is released.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 6, 2026): <!-- Answer --> This error happens because the SendEmailToolParameters model requires a sender_address field, but send_mail_batch.py only provides email_account, not sender_address. This mismatch triggers the Pydantic ValidationError you’re seeing. The issue is confirmed in recent reports and is due to send_mail_batch.py not using sender_address from credentials, unlike send_mail.py, which does this correctly. The recommended fix is to update send_mail_batch.py to fetch sender_address from credentials (falling back to email_account if missing) and pass it to SendEmailToolParameters, matching the logic in send_mail.py. You can find more details and the suggested code change in [issue #838](https://github.com/langgenius/dify-official-plugins/issues/838) and [issue #1085](https://github.com/langgenius/dify-official-plugins/issues/1085). As a temporary workaround, you can patch your local send_mail_batch.py by adding: ```python sender_address = self.runtime.credentials.get("sender_address", sender) # ... send_email_params = SendEmailToolParameters( smtp_server=smtp_server, smtp_port=smtp_port, email_account=sender, email_password=password, sender_address=sender_address, # ... other fields ... ) ``` This should resolve the validation error until an official fix is released. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/a3b64d85-8e38-405c-94da-c2d17308c15b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/a3b64d85-8e38-405c-94da-c2d17308c15b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/a3b64d85-8e38-405c-94da-c2d17308c15b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/a3b64d85-8e38-405c-94da-c2d17308c15b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a3b64d85-8e38-405c-94da-c2d17308c15b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/a3b64d85-8e38-405c-94da-c2d17308c15b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/a3b64d85-8e38-405c-94da-c2d17308c15b?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20error%20happens%20because%20the%20SendEmailToolParameters%20model%20requires%20a%20sender_address%20field%2C%20but%20send_mail_batch.py%20only%20provides%20email_account%2C%20not%20sender_address.%20This%20mismatch%20triggers%20the%20Pydantic%20ValidationError%20you%E2%80%99re%20seeing.%20The%20issue%20is%20confirmed%20in%20recent%20reports%20and%20is%20due%20to%20send_mail_batch.py%20not%20using%20sender_address%20from%20credentials%2C%20unlike%20send_mail.py%2C%20which%20does%20this%20correctly.%20The%20recommended%20fix%20is%20to%20update%20send_mail_batch.py%20to%20fetch%20sender_address%20from%20credentials%20%28falling%20back%20to%20email_account%20if%20missing%29%20and%20pass%20it%20to%20SendEmailToolParameters%2C%20matching%20the%20logic%20in%20send_mail.py.%20You%20can%20find%20more%20details%20and%20the%20suggested%20code%20change%20in%20%5Bissue%20%23838%5D%28https%3A//github.com/langgenius/dify-official-plugins/issues/838%29%20and%20%5Bissue%20%231085%5D%28https%3A//github.com/langgenius/dify-official-plugins/issues/1085%29.%0A%0AAs%20a%20temporary%20workaround%2C%20you%20can%20patch%20your%20local%20send_mail_batch.py%20by%20adding%3A%0A%60%60%60python%0Asender_address%20%3D%20self.runtime.credentials.get%28%22sender_address%22%2C%20sender%29%0A%23%20...%0Asend_email_params%20%3D%20SendEmailToolParameters%28%0A%20%20%20%20smtp_server%3Dsmtp_server%2C%0A%20%20%20%20smtp_port%3Dsmtp_port%2C%0A%20%20%20%20email_account%3Dsender%2C%0A%20%20%20%20email_password%3Dpassword%2C%0A%20%20%20%20sender_address%3Dsender_address%2C%0A%20%20%20%20%23%20...%20other%20fields%20...%0A%29%0A%60%60%60%0AThis%20should%20resolve%20the%20validation%20error%20until%20an%20official%20fix%20is%20released.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2369)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#917