ValiMail / authentication-headers

library for the generation of email authentication headers
Other
16 stars 4 forks source link

AttributeError: 'str' object has no attribute 'quote_if_needed' #16

Closed niftylettuce closed 2 years ago

niftylettuce commented 4 years ago
20|smtp  | Error: Traceback (most recent call last):
20|smtp  |   File "/var/www/production/source/node_modules/authheaders/scripts/authenticate-message.py", line 36, in <module>
20|smtp  |     main()
20|smtp  |   File "/var/www/production/source/node_modules/authheaders/scripts/authenticate-message.py", line 25, in main
20|smtp  |     header = authheaders.authenticate_message(msg=message, authserv_id=authservId, ip=ip, mail_from=mailFrom, helo=helo, spf=True, dkim=True, arc=True)
20|smtp  |   File "/home/deploy/.local/lib/python3.6/site-packages/authheaders/__init__.py", line 298, in authenticate_message
20|smtp  |     return str(auth_res)
20|smtp  |   File "/home/deploy/.local/lib/python3.6/site-packages/authres/core.py", line 476, in __str__
20|smtp  |     return ''.join((self.HEADER_FIELD_NAME, ': ', self.header_value()))
20|smtp  |   File "/home/deploy/.local/lib/python3.6/site-packages/authres/core.py", line 492, in header_value
20|smtp  |     strs.append(str(result))
20|smtp  |   File "/home/deploy/.local/lib/python3.6/site-packages/authres/core.py", line 222, in __str__
20|smtp  |     strs.append(str(property_))
20|smtp  |   File "/home/deploy/.local/lib/python3.6/site-packages/authres/core.py", line 132, in __str__
20|smtp  |     return '%s.%s=%s' % (self.type, self.name, self.value.quote_if_needed())
20|smtp  | AttributeError: 'str' object has no attribute 'quote_if_needed'
20|smtp  |     at ChildProcess.<anonymous> (/var/www/production/source/node_modules/authheaders/index.js:61:44)
20|smtp  |     at ChildProcess.emit (events.js:323:22)
20|smtp  |     at maybeClose (internal/child_process.js:1021:16)
20|smtp  |     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)

You can see the error occurs here in the code:

return '%s.%s=%s' % (self.type, self.name, self.value.quote_if_needed())

kitterma commented 3 years ago

The actual traceback comes from authres. It looks like we're passing a string to it when it should be of type AuthenticationResultProperty or something like that.

kitterma commented 3 years ago

The str conversion is in authres, so I think this is an authres issue. I'll close this once I've confirmed that and opened a bug against it.

kitterma commented 3 years ago

I'm less convinced now that I've studied this some more. In all the tests we have, self.value is either <class 'NoneType'> or .<class 'authres.core.QuotableValue'>, neither of which could raise that error. The same is true of the tests for authres. I don't see how it's possible to stuff a string into there and get to that point. This will need a test case or some further information.

niftylettuce commented 2 years ago

See https://github.com/ValiMail/authentication-headers/issues/19#issuecomment-1014955652 for closing comment.