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

500 Internal Server Error #2209

Closed ghost closed 7 months ago

ghost commented 7 months ago

Version 0.45.14

I'm using changedetection.io Docker image. Unexpectedly, trying to access port 5000 results in receiving an Internal Server Error. In the container logs, the following error can be seen:

[2024-02-22 15:49:12,914] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/jinja2/environment.py", line 466, in getitem
    return obj[argument]
           ~~~^^^^^^^^^^
KeyError: 'last_changed'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/flask_restful/__init__.py", line 298, in error_router
    return original_handler(e)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/changedetectionio/flask_app.py", line 208, in decorated_view
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/changedetectionio/flask_app.py", line 460, in index
    output = render_template(
             ^^^^^^^^^^^^^^^^
  File "/usr/local/flask/templating.py", line 151, in render_template
    return _render(app, template, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/flask/templating.py", line 132, in _render
    rv = template.render(context)
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/app/changedetectionio/templates/watch-overview.html", line 1, in top-level template code
    {% extends 'base.html' %}
  File "/app/changedetectionio/templates/base.html", line 207, in top-level template code
    {% block content %}{% endblock %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/changedetectionio/templates/watch-overview.html", line 81, in block 'content'
    {% for watch in (watches|sort(attribute=sort_attribute, reverse=sort_order == 'asc'))|pagination_slice(skip=pagination.skip) %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/jinja2/filters.py", line 423, in do_sort
    return sorted(value, key=key_func, reverse=reverse)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/jinja2/filters.py", line 112, in attrgetter
    item_i = environment.getitem(item_i, part)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/jinja2/environment.py", line 475, in getitem
    return getattr(obj, attr)
           ^^^^^^^^^^^^^^^^^^
  File "/app/changedetectionio/model/Watch.py", line 193, in last_changed
    return int(self.__newest_history_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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\x00\x00\x0

I haven't made any changes in the configuration. After seeing the error, I updated the containers dgtlmoon/changedetection.io and browserless/chrome to the latest builds, but it didn't resolve the described issue.

dgtlmoon commented 7 months ago

it means the url-watches.json file is corrupt, but actually its not "that" corrupt, all you need todo is edit the file and remove those \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\x00\x00\x0's

you will see in the file that there is large blank spots

it can happen when the machine is turned off by accident, docker image killed without waiting while its writing the db etc

ghost commented 7 months ago

Thank you. These characters didn't appear in url-watches.json, but were present in two history.txt files. Deleting these corrupted files resolved the issue.