Coder Social home page Coder Social logo

Breaking change, no documentation for it: Invalid type for parameter FeedbackForwardingEmailAddress, value: None, type: <class 'NoneType'>, valid types: <class 'str'> about django-ses HOT 9 CLOSED

metalaureate avatar metalaureate commented on June 28, 2024
Breaking change, no documentation for it: Invalid type for parameter FeedbackForwardingEmailAddress, value: None, type: , valid types:

from django-ses.

Comments (9)

pcraciunoiu avatar pcraciunoiu commented on June 28, 2024 2

It sounds like a value needs to be set for AWS_SES_RETURN_PATH even though it's expected to be optional. That might be your short-term fix for now.

@peidrao can you fix so it can be optional in a follow-up?

from django-ses.

pcraciunoiu avatar pcraciunoiu commented on June 28, 2024 2

This has been fixed in #279 and released as v3.4.1 on PyPi

Thanks for the quick fix!

from django-ses.

peidrao avatar peidrao commented on June 28, 2024 1

I'll check it

from django-ses.

pcraciunoiu avatar pcraciunoiu commented on June 28, 2024 1

@rodrigondec skipping the param when it's None makes sense to me. Go ahead and PR that and I'll release a patch version. If you can't reproduce the issue by setting to None on v3.4.0, we can have the reporting user test it.

But worth a try if you can reproduce it with None (or omitting the setting). Make sure USE_SES_V2 is set

from django-ses.

rodrigondec avatar rodrigondec commented on June 28, 2024 1

Problem reproduced

Traceback (most recent call last):
File "/home/rodrigondec/prog/imobanco/income-back/.venv/lib/python3.9/site-packages/django/core/mail/message.py", line 284, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/home/rodrigondec/prog/imobanco/income-back/.venv/lib/python3.9/site-packages/django_ses/__init__.py", line 166, in send_messages
    response = (self.connection.send_email(**kwargs)
  File "/home/rodrigondec/prog/imobanco/income-back/.venv/lib/python3.9/site-packages/botocore/client.py", line 530, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/rodrigondec/prog/imobanco/income-back/.venv/lib/python3.9/site-packages/botocore/client.py", line 919, in _make_api_call
    request_dict = self._convert_to_request_dict(
  File "/home/rodrigondec/prog/imobanco/income-back/.venv/lib/python3.9/site-packages/botocore/client.py", line 990, in _convert_to_request_dict
    request_dict = self._serializer.serialize_to_request(
  File "/home/rodrigondec/prog/imobanco/income-back/.venv/lib/python3.9/site-packages/botocore/validate.py", line 381, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter FeedbackForwardingEmailAddress, value: None, type: <class 'NoneType'>, valid types: <class 'str'>

We verified the solution performing a regression test using the install from the branch on our fork https://github.com/imobanco/django-ses/tree/fix/feedback_none.

from django-ses.

metalaureate avatar metalaureate commented on June 28, 2024 1

Thank you!

from django-ses.

pcraciunoiu avatar pcraciunoiu commented on June 28, 2024

@peidrao @rodrigondec have you come across this? Is it related to the change in #276 ?

Does this issue happen in v3.3.0 too @metalaureate ? If not, it could have to do with the from address not being verified. See here: #276 (comment)

from django-ses.

metalaureate avatar metalaureate commented on June 28, 2024

from django-ses.

rodrigondec avatar rodrigondec commented on June 28, 2024

We forgot to check if email_feedback is None to use the arg FeedbackForwardingEmailAddress

def _get_v2_parameters(self, message, source, email_feedback):
"""V2-Style raw payload for `send_email`.
https://boto3.amazonaws.com/v1/documentation/api/1.26.31/reference/services/sesv2.html#SESV2.Client.send_email
"""
params = dict(
FeedbackForwardingEmailAddress=email_feedback,
FromEmailAddress=source or message.from_email,
Destination={
'ToAddresses': message.recipients()
},
Content={
'Raw': {
'Data': dkim_sign(message.message().as_string(),
dkim_key=self.dkim_key,
dkim_domain=self.dkim_domain,
dkim_selector=self.dkim_selector,
dkim_headers=self.dkim_headers)
}
}
)
if self.ses_from_arn or self.ses_source_arn:
params['FromEmailAddressIdentityArn'] = self.ses_from_arn or self.ses_source_arn
return params

I think this would resolve the issue

     def _get_v2_parameters(self, message, source, email_feedback): 
         """V2-Style raw payload for `send_email`. 
  
         https://boto3.amazonaws.com/v1/documentation/api/1.26.31/reference/services/sesv2.html#SESV2.Client.send_email 
         """ 
         params = dict(  
             FromEmailAddress=source or message.from_email, 
             Destination={ 
                 'ToAddresses': message.recipients() 
             }, 
             Content={ 
                 'Raw': { 
                     'Data': dkim_sign(message.message().as_string(), 
                                       dkim_key=self.dkim_key, 
                                       dkim_domain=self.dkim_domain, 
                                       dkim_selector=self.dkim_selector, 
                                       dkim_headers=self.dkim_headers) 
                 } 
             } 
         ) 
         if self.ses_from_arn or self.ses_source_arn: 
             params['FromEmailAddressIdentityArn'] = self.ses_from_arn or self.ses_source_arn 
         if email_feedback is not None:
             params['FeedbackForwardingEmailAddress'] = email_feedback
         return params 

To be sure that this is the error I would need to reproduce the error and the full stack trace. But my guess is that this error is a validation error from the lib boto3. The arg FeedbackForwardingEmailAddress=None must be invalid and the arg should not be used without value.

from django-ses.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.