question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError in get_url()

See original GitHub issue

Description 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

  1. Trying in console, I see that
frappe.local.conf.wildcard

returns the wildcard section of the common_site_config.json.

  1. 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:open
  • Created 2 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
ryuliantorocommented, Oct 19, 2021

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.

0reactions
gavindsouzacommented, Aug 9, 2022

certbot-auto was deprecated so we had to replace it with certbot 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'module' object has no attribute 'urlopen'
This works in Python 2.x. For Python 3 look in the docs: import urllib.request with urllib.request.urlopen("http://www.python.org") as url: s = url.read() ...
Read more >
AttributeError: 'HTTPResponse' object has no attribute 'geturl ...
Python error when cloning: AttributeError: 'HTTPResponse' object ... You need a newer version of urllib3; older versions don't have geturl().
Read more >
R = request.get(url) attributeerror: 'request' object has no ...
Because r is a " NoneType ", that is to say it has not been set to a valid reference. So look at...
Read more >
[Tutor] AttributeError: 'str' object has no ... - tutor@python.org
Class Data has a class attribute, 'f', defined as an empty string. Check if Data.f is initialized before calling getImg. Also, why initialize...
Read more >
[Tutor] AttributeError: 'str' object has no attribute 'geturl'
todayStrip) > File "F:\Gacor\getgarf.py", line 127, in getImg > Data.f.geturl() > AttributeError: 'str' object has no attribute 'geturl' > Class Data has a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found