AttributeError in get_url()
See original GitHub issueDescription of the issue
I made a function that sends email using the built-in send_mail() function. But it raised error when reach the step getting url.
The error points to line 789 of data.py. I looked up the data.py and found this line
domain = frappe.local.conf.wildcard.get('domain')
According to the error message, the frappe.local.conf.wildcard
(which is a list) doesn’t have get
attribute.
Context information (for bug reports)
Output of bench version
erpnext 12.25.0
frappe 12.22.2
Steps to reproduce the issue
- Trying in console, I see that
frappe.local.conf.wildcard
returns the wildcard section of the common_site_config.json.
- But it generate the error when I add
get
attribute
AttributeError: 'list' object has no attribute 'get'
The same happen if I use:
frappe.local.conf.domains.get('domain')
Observed result
I think this issue happened since last week when I update frappe from version 12.18 to 12.21. Now that I update it again to 12.22.2 it still has this issue.
If I remove the widlcard entry from common_site_config.json, the code doesn’t raise the error. And the email is sent.
Or if I use frappe.local.conf.get('a_key_in_config')
it returns a value. In this case, the key must be a single key, not a list.
Expected result
I think this line 789 of data.py should be something like:
elif frappe.local.conf.wildcard:
domain = frappe.local.conf.wildcard[0]['domain']
if domain and frappe.local.site.endswith(domain) and frappe.local.conf.wildcard[0]['ssl_certificate']:
protocol = 'https://'
Stacktrace / full error message
File "/home/adminuser/bench/apps/frappe/frappe/__init__.py", line 492, in sendmail
inline_images=inline_images, header=header, print_letterhead=print_letterhead)
File "/home/adminuser/bench/apps/frappe/frappe/email/queue.py", line 135, in send
unsubscribe_link=unsubscribe_link)
File "/home/adminuser/bench/apps/frappe/frappe/email/email_body.py", line 287, in get_formatted_html
html = scrub_urls(rendered_email)
File "/home/adminuser/bench/apps/frappe/frappe/utils/data.py", line 1008, in scrub_urls
html = expand_relative_urls(html)
File "/home/adminuser/bench/apps/frappe/frappe/utils/data.py", line 1015, in expand_relative_urls
url = get_url()
File "/home/adminuser/bench/apps/frappe/frappe/utils/data.py", line 789, in get_url
domain = frappe.local.conf.wildcard.get('domain')
AttributeError: 'list' object has no attribute 'get'
Additional information
OS version: CentOS 8.4 / AlmaLinux 8.4 Frappe install method: manual
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (12 by maintainers)
Top GitHub Comments
OK. I found the culprit. I just remember that I restore some sites and yes manually put back the wildcard key because the bench command no longer works for wildcard. I compare with some other sites, the value is a List instead of Dict. I mistakenly put [] in it. So no code mistake nor bug.
certbot-auto
was deprecated so we had to replace it withcertbot
instead via https://github.com/frappe/bench/pull/1303 (Bench v5.9.0) [Current version v5.14.1 btw]The commands were never deprecated through Bench, the dependencies were by third parties. The same commands should work just fine @ryuliantoro