dgtlmoon / changedetection.io

The best and simplest free open source web page change detection, website watcher, restock monitor and notification service. Restock Monitor, change detection. Designed for simplicity - Simply monitor which websites had a text change for free. Free Open source web page change detection, Website defacement monitoring, Price change notification
https://changedetection.io
Apache License 2.0
17.3k stars 965 forks source link

Internal Server Error received when trying to access the Changedetection website hosted locally #2038

Closed sangpham2710 closed 10 months ago

sangpham2710 commented 10 months ago

Describe the bug Can't access to the website of changedetection.io after running docker-compose up, and it shows errors in the log of the container (full log below)

Version 0.45.8.1

To Reproduce

Steps to reproduce the behavior:

  1. Go to localhost:8000
  2. See error

Expected behavior See the changedetection page

Screenshots image

Desktop (please complete the following information):

Additional context The log of the container shows errors 2023-12-08 11:01:28 System env MINIMUM_SECONDS_RECHECK_TIME 20 2023-12-08 11:01:28 (7) wsgi starting up on http://0.0.0.0:54321 2023-12-08 11:01:29 (7) accepted ('172.20.0.1', 51876) 2023-12-08 11:01:29 ERROR:changedetectionio:Exception on / [GET] 2023-12-08 11:01:29 Traceback (most recent call last): 2023-12-08 11:01:29 File "/usr/local/jinja2/environment.py", line 466, in getitem 2023-12-08 11:01:29 return obj[argument] 2023-12-08 11:01:29 ~~~^^^^^^^^^^ 2023-12-08 11:01:29 KeyError: 'last_changed' 2023-12-08 11:01:29 2023-12-08 11:01:29 During handling of the above exception, another exception occurred: 2023-12-08 11:01:29 2023-12-08 11:01:29 Traceback (most recent call last): 2023-12-08 11:01:29 File "/usr/local/flask/app.py", line 2190, in wsgi_app 2023-12-08 11:01:29 response = self.full_dispatch_request() 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/usr/local/flask/app.py", line 1486, in full_dispatch_request 2023-12-08 11:01:29 rv = self.handle_user_exception(e) 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/usr/local/flask_restful/init.py", line 298, in error_router 2023-12-08 11:01:29 return original_handler(e) 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/usr/local/flask/app.py", line 1484, in full_dispatch_request 2023-12-08 11:01:29 rv = self.dispatch_request() 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/usr/local/flask/app.py", line 1469, in dispatch_request 2023-12-08 11:01:29 return self.ensure_sync(self.view_functions[rule.endpoint])(*view_args) 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/app/changedetectionio/init.py", line 212, in decorated_view 2023-12-08 11:01:29 return func(args, **kwargs) 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/app/changedetectionio/init.py", line 450, in index 2023-12-08 11:01:29 output = render_template( 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/usr/local/flask/templating.py", line 151, in render_template 2023-12-08 11:01:29 return _render(app, template, context) 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/usr/local/flask/templating.py", line 132, in _render 2023-12-08 11:01:29 rv = template.render(context) 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/usr/local/jinja2/environment.py", line 1301, in render 2023-12-08 11:01:29 self.environment.handle_exception() 2023-12-08 11:01:29 File "/usr/local/jinja2/environment.py", line 936, in handle_exception 2023-12-08 11:01:29 raise rewrite_traceback_stack(source=source) 2023-12-08 11:01:29 File "/app/changedetectionio/templates/watch-overview.html", line 1, in top-level template code 2023-12-08 11:01:29 {% extends 'base.html' %} 2023-12-08 11:01:29 File "/app/changedetectionio/templates/base.html", line 207, in top-level template code 2023-12-08 11:01:29 {% block content %}{% endblock %} 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/app/changedetectionio/templates/watch-overview.html", line 81, in block 'content' 2023-12-08 11:01:29 {% for watch in (watches|sort(attribute=sort_attribute, reverse=sort_order == 'asc'))|pagination_slice(skip=pagination.skip) %} 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/usr/local/jinja2/filters.py", line 409, in do_sort 2023-12-08 11:01:29 return sorted(value, key=key_func, reverse=reverse) 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/usr/local/jinja2/filters.py", line 112, in attrgetter 2023-12-08 11:01:29 item_i = environment.getitem(item_i, part) 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/usr/local/jinja2/environment.py", line 475, in getitem 2023-12-08 11:01:29 return getattr(obj, attr) 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 File "/app/changedetectionio/model/Watch.py", line 189, in last_changed 2023-12-08 11:01:29 return int(self.__newest_history_key) 2023-12-08 11:01:29 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2023-12-08 11:01:29 ValueError: invalid literal for int() with base 10: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x001701929 2023-12-08 11:01:29 172.20.0.1 - - [08/Dec/2023 04:01:29] "GET / HTTP/1.1" 500 456 0.093203

dgtlmoon commented 10 months ago

Heya

So unfortunately your url-watches.json has a slight corruption - its possible the machine ran out of disk or the process was terminated without waiting for it to write all the DB properly

However - it is savable - close down your changedetection instance, then edit the url-watches.json by hand, if you scroll down far enough you will see a big empty value (full of spaces) in the JSON document, just trim all those out, then you should be good to go

but you didnt say anything about how you're running it (docker/pip/windows/whatever) so I cant help much further

https://github.com/dgtlmoon/changedetection.io/pull/2014 might have helped to address some of this

sangpham2710 commented 10 months ago

I fixed it by manually recreating the container and deleting the volume, then edit url-watches.json by copying the old one to the new one (because I don't see how the content of the file is corrupted). So it seems like the JSON file is not the problem here.

Anyway I got it worked through your instructions, thank you for your time.

codedesperate commented 6 months ago

Hmm, I tried deleting the docker image and the volume, and just do a fresh install. I'm still getting Internal Server Error. Not every time though, but like on every third refresh on the website?

dgtlmoon commented 6 months ago

@codedesperate cant do anything without more information, we need to see the logs.. (attach them as a .zip or .txt file, dont past screenshots)

codedesperate commented 6 months ago

I got it working in the end. :) https://github.com/dgtlmoon/changedetection.io/issues/2287