[Solved] DNS entries listing results in error 500

Hi there.

I have been running a MIAB for years and am still very happy with it.
With updates and even the move from 16.04 to 18.04 everythings works nice.

But since probably 9 months or so, the website for listing the customDNS returns an error 500.
This error stems from the underlying API endpoint, the “secondary-nameservers” and “zones” endpoints are working, but the “custom” endpoint returns the error. The request itself looks fine and even if I use another API client (insomnia in this case) or even just curl, the same happens.

I am pretty sure, it results from an entry, that somehow messes the listing up.

From the logs was able to pinpoint it:

==> /var/log/syslog <==
Dec 29 20:41:48 box start[6586]: 127.0.0.1 - - [29/Dec/2021 20:41:48] "GET /dns/secondary-nameserver?_=1640806284715 HTTP/1.0" 200 -
Dec 29 20:41:49 box start[6586]: 127.0.0.1 - - [29/Dec/2021 20:41:49] "GET /dns/zones?_=1640806284716 HTTP/1.0" 200 -
Dec 29 20:41:49 box start[6586]: [2021-12-29 20:41:49,094] ERROR in app: Exception on /dns/custom [GET]
Dec 29 20:41:49 box start[6586]: Traceback (most recent call last):
Dec 29 20:41:49 box start[6586]:   File "/usr/local/lib/mailinabox/env/lib/python3.6/site-packages/flask/app.py", line 2073, in wsgi_app
Dec 29 20:41:49 box start[6586]:     response = self.full_dispatch_request()
Dec 29 20:41:49 box start[6586]:   File "/usr/local/lib/mailinabox/env/lib/python3.6/site-packages/flask/app.py", line 1518, in full_dispatch_request
Dec 29 20:41:49 box start[6586]:     rv = self.handle_user_exception(e)
Dec 29 20:41:49 box start[6586]:   File "/usr/local/lib/mailinabox/env/lib/python3.6/site-packages/flask/app.py", line 1516, in full_dispatch_request
Dec 29 20:41:49 box start[6586]:     rv = self.dispatch_request()
Dec 29 20:41:49 box start[6586]:   File "/usr/local/lib/mailinabox/env/lib/python3.6/site-packages/flask/app.py", line 1502, in dispatch_request
Dec 29 20:41:49 box start[6586]:     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
Dec 29 20:41:49 box start[6586]:   File "/root/mailinabox/management/daemon.py", line 75, in newview
Dec 29 20:41:49 box start[6586]:     return viewfunc(*args, **kwargs)
Dec 29 20:41:49 box start[6586]:   File "/root/mailinabox/management/daemon.py", line 332, in dns_get_records
Dec 29 20:41:49 box start[6586]:     for i, r in enumerate(sorted(records, key = lambda r : (
Dec 29 20:41:49 box start[6586]:   File "/root/mailinabox/management/daemon.py", line 333, in <lambda>
Dec 29 20:41:49 box start[6586]:     zones.index(r["zone"]),
Dec 29 20:41:49 box start[6586]: KeyError: 'zone'
Dec 29 20:41:49 box start[6586]: 127.0.0.1 - - [29/Dec/2021 20:41:49] "#033[35m#033[1mGET /dns/custom?_=1640806284717 HTTP/1.0#033[0m" 500 -
Dec 29 20:41:49 box Exception on /dns/custom [GET]#012Traceback (most recent call last):#012  File "/usr/local/lib/mailinabox/env/lib/python3.6/site-packages/flask/app.py", line 2073, in wsgi_app#012    response = self.full_dispatch_request()#012  File "/usr/local/lib/mailinabox/env/lib/python3.6/site-packages/flask/app.py", line 1518, in full_dispatch_request#012    rv = self.handle_user_exception(e)#012  File "/usr/local/lib/mailinabox/env/lib/python3.6/site-packages/flask/app.py", line 1516, in full_dispatch_request#012    rv = self.dispatch_request()#012  File "/usr/local/lib/mailinabox/env/lib/python3.6/site-packages/flask/app.py", line 1502, in dispatch_request#012    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)#012  File "/root/mailinabox/management/daemon.py", line 75, in newview#012    return viewfunc(*args, **kwargs)#012  File "/root/mailinabox/management/daemon.py", line 332, in dns_get_records#012    for i, r in enumerate(sorted(records, key = lambda r : (#012  File "/root/mailinabox/management/daemon.py", line 333, in <lambda>#012    zones.index(r["zone"]),#012KeyError: 'zone

Python is not my strong suit, so I decided to ask if anybody here has an idea.

Thank you very much.

PS: reinstalling or even upgrading doesn’t fix it. it has been this way since a few smaller version bumps

PPS: Also I’d like to say thanks to everybody participating in this amazing project, you are awesome !

Do you have any old domains listed in /home/user-data/dns/custom.yaml?

1 Like

Thank you very much, I actually had a domain listed, that had been disabled in the meantime.

After manually going through the file based configuration, and getting rid of old entries it started to work again.

Since this is something, that could happen to anybody anytime, it could be an improvement, to catch that error and shown a more meaningful message to the user. Maybe even pointing to the file to validate the entries of.

Anyways, your answer solved this issue, thank you again. :grinning:

1 Like