[GH-ISSUE #694] Bug: Adding tags to an existing snapshot throws a server error (500) #435

Closed
opened 2026-03-01 14:43:35 +03:00 by kerem · 2 comments
Owner

Originally created by @erob8 on GitHub (Apr 7, 2021).
Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/694

Describe the bug

Adding tags to an existing snapshot throws a server error (500)

Steps to reproduce

  1. I'm using docker-compose with sonic enabled and otherwise the default config file.
  2. After going to the /admin/core/snapshot view and clicking a box on the left to select an article, i click the button 'add tags' which returns a Server Error (500)

Screenshots or log output

docker-compose logs:

archivebox_1  | Traceback (most recent call last):
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
archivebox_1  |     response = get_response(request)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
archivebox_1  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/contrib/admin/options.py", line 614, in wrapper
archivebox_1  |     return self.admin_site.admin_view(view)(*args, **kwargs)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
archivebox_1  |     response = view_func(request, *args, **kwargs)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
archivebox_1  |     response = view_func(request, *args, **kwargs)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 233, in inner
archivebox_1  |     return view(request, *args, **kwargs)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
archivebox_1  |     return bound_method(*args, **kwargs)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
archivebox_1  |     response = view_func(request, *args, **kwargs)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1719, in changelist_view
archivebox_1  |     response = self.response_action(request, queryset=cl.get_queryset(request))
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1402, in response_action
archivebox_1  |     response = func(self, request, queryset)
archivebox_1  |   File "/app/archivebox/core/admin.py", line 218, in add_tag
archivebox_1  |     obj.tags.add(tag)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related_descriptors.py", line 950, in add
archivebox_1  |     self._add_items(
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related_descriptors.py", line 1126, in _add_items
archivebox_1  |     target_ids = self._get_target_ids(target_field_name, objs)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related_descriptors.py", line 1073, in _get_target_ids
archivebox_1  |     target_ids.add(target_field.get_prep_value(obj))
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 977, in get_prep_value
archivebox_1  |     return self.target_field.get_prep_value(value)
archivebox_1  |   File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1776, in get_prep_value
archivebox_1  |     raise e.__class__(
archivebox_1  | ValueError: Field 'id' expected a number but got ''.

The request payload I'm sending which shows &tag= which is the source of the issue I imagine. Opening the index.sqlite3 file and examining the core_snapshot table shows a non-null id as expected.

csrfmiddlewaretoken=k7UGcaLI0w0vRBgfWrDjOjfIkTcxwPOJsCVZMEV0AnUzW5r5vqyMEpc7KQq4CBIo&action=add_tag&select_across=0&tag=&index=0&_selected_action=45d3506e-8b69-4ab8-af5c-dafb198d8ed0

ArchiveBox version

➜  archivebox docker-compose run archivebox version
Creating archivebox_archivebox_run ... done
ArchiveBox v0.6.0
Cpython Linux Linux-4.19.128-microsoft-standard-x86_64-with-glibc2.28 x86_64
IN_DOCKER=True DEBUG=False IS_TTY=True TZ=UTC SEARCH_BACKEND_ENGINE=sonic

[i] Dependency versions:
 √  ARCHIVEBOX_BINARY     v0.6.0          valid     /usr/local/bin/archivebox
 √  PYTHON_BINARY         v3.9.4          valid     /usr/local/bin/python3.9
 √  DJANGO_BINARY         v3.1.7          valid     /usr/local/lib/python3.9/site-packages/django/bin/django-admin.py
 √  CURL_BINARY           v7.64.0         valid     /usr/bin/curl
 √  WGET_BINARY           v1.20.1         valid     /usr/bin/wget
 √  NODE_BINARY           v15.13.0        valid     /usr/bin/node
 √  SINGLEFILE_BINARY     v0.3.16         valid     /node/node_modules/single-file/cli/single-file
 √  READABILITY_BINARY    v0.0.2          valid     /node/node_modules/readability-extractor/readability-extractor
 √  MERCURY_BINARY        v1.0.0          valid     /node/node_modules/@postlight/mercury-parser/cli.js
 √  GIT_BINARY            v2.20.1         valid     /usr/bin/git
 √  YOUTUBEDL_BINARY      v2021.04.01     valid     /usr/local/bin/youtube-dl
 √  CHROME_BINARY         v88.0.4324.182  valid     /usr/bin/chromium
 √  RIPGREP_BINARY        v0.10.0         valid     /usr/bin/rg

[i] Source-code locations:
 √  PACKAGE_DIR           22 files        valid     /app/archivebox
 √  TEMPLATES_DIR         3 files         valid     /app/archivebox/templates

[i] Secrets locations:
 -  CHROME_USER_DATA_DIR  -               disabled
 -  COOKIES_FILE          -               disabled

[i] Data locations:
 √  OUTPUT_DIR            9 files         valid     /data
 √  SOURCES_DIR           6 files         valid     ./sources
 √  LOGS_DIR              1 files         valid     ./logs
 √  ARCHIVE_DIR           2 files         valid     ./archive
 √  CONFIG_FILE           81.0 Bytes      valid     ./ArchiveBox.conf
 √  SQL_INDEX             460.0 KB        valid     ./index.sqlite3
Originally created by @erob8 on GitHub (Apr 7, 2021). Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/694 <!-- Please fill out the following information, feel free to delete sections if they're not applicable or if long issue templates annoy you. (the only required section is the version information) --> #### Describe the bug Adding tags to an existing snapshot throws a server error (500) #### Steps to reproduce <!-- For example: 1. Ran ArchiveBox with the following config '...' 2. Saw this output during archiving '....' 3. UI didn't show the thing I was expecting '....' --> 1. I'm using docker-compose with sonic enabled and otherwise the default config file. 2. After going to the /admin/core/snapshot view and clicking a box on the left to select an article, i click the button 'add tags' which returns a Server Error (500) #### Screenshots or log output <!-- If applicable, post any relevant screenshots or copy/pasted terminal output from ArchiveBox. If you're reporting a parsing / importing error, **you must paste a copy of your redacted import file here**. --> docker-compose logs: ```log archivebox_1 | Traceback (most recent call last): archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner archivebox_1 | response = get_response(request) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response archivebox_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/contrib/admin/options.py", line 614, in wrapper archivebox_1 | return self.admin_site.admin_view(view)(*args, **kwargs) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view archivebox_1 | response = view_func(request, *args, **kwargs) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func archivebox_1 | response = view_func(request, *args, **kwargs) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 233, in inner archivebox_1 | return view(request, *args, **kwargs) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper archivebox_1 | return bound_method(*args, **kwargs) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view archivebox_1 | response = view_func(request, *args, **kwargs) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1719, in changelist_view archivebox_1 | response = self.response_action(request, queryset=cl.get_queryset(request)) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1402, in response_action archivebox_1 | response = func(self, request, queryset) archivebox_1 | File "/app/archivebox/core/admin.py", line 218, in add_tag archivebox_1 | obj.tags.add(tag) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related_descriptors.py", line 950, in add archivebox_1 | self._add_items( archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related_descriptors.py", line 1126, in _add_items archivebox_1 | target_ids = self._get_target_ids(target_field_name, objs) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related_descriptors.py", line 1073, in _get_target_ids archivebox_1 | target_ids.add(target_field.get_prep_value(obj)) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 977, in get_prep_value archivebox_1 | return self.target_field.get_prep_value(value) archivebox_1 | File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1776, in get_prep_value archivebox_1 | raise e.__class__( archivebox_1 | ValueError: Field 'id' expected a number but got ''. ``` The request payload I'm sending which shows `&tag=` which is the source of the issue I imagine. Opening the index.sqlite3 file and examining the core_snapshot table shows a non-null id as expected. `csrfmiddlewaretoken=k7UGcaLI0w0vRBgfWrDjOjfIkTcxwPOJsCVZMEV0AnUzW5r5vqyMEpc7KQq4CBIo&action=add_tag&select_across=0&tag=&index=0&_selected_action=45d3506e-8b69-4ab8-af5c-dafb198d8ed0` #### ArchiveBox version <!-- Run the `archivebox version` command locally then copy paste the result here: --> ```logs ➜ archivebox docker-compose run archivebox version Creating archivebox_archivebox_run ... done ArchiveBox v0.6.0 Cpython Linux Linux-4.19.128-microsoft-standard-x86_64-with-glibc2.28 x86_64 IN_DOCKER=True DEBUG=False IS_TTY=True TZ=UTC SEARCH_BACKEND_ENGINE=sonic [i] Dependency versions: √ ARCHIVEBOX_BINARY v0.6.0 valid /usr/local/bin/archivebox √ PYTHON_BINARY v3.9.4 valid /usr/local/bin/python3.9 √ DJANGO_BINARY v3.1.7 valid /usr/local/lib/python3.9/site-packages/django/bin/django-admin.py √ CURL_BINARY v7.64.0 valid /usr/bin/curl √ WGET_BINARY v1.20.1 valid /usr/bin/wget √ NODE_BINARY v15.13.0 valid /usr/bin/node √ SINGLEFILE_BINARY v0.3.16 valid /node/node_modules/single-file/cli/single-file √ READABILITY_BINARY v0.0.2 valid /node/node_modules/readability-extractor/readability-extractor √ MERCURY_BINARY v1.0.0 valid /node/node_modules/@postlight/mercury-parser/cli.js √ GIT_BINARY v2.20.1 valid /usr/bin/git √ YOUTUBEDL_BINARY v2021.04.01 valid /usr/local/bin/youtube-dl √ CHROME_BINARY v88.0.4324.182 valid /usr/bin/chromium √ RIPGREP_BINARY v0.10.0 valid /usr/bin/rg [i] Source-code locations: √ PACKAGE_DIR 22 files valid /app/archivebox √ TEMPLATES_DIR 3 files valid /app/archivebox/templates [i] Secrets locations: - CHROME_USER_DATA_DIR - disabled - COOKIES_FILE - disabled [i] Data locations: √ OUTPUT_DIR 9 files valid /data √ SOURCES_DIR 6 files valid ./sources √ LOGS_DIR 1 files valid ./logs √ ARCHIVE_DIR 2 files valid ./archive √ CONFIG_FILE 81.0 Bytes valid ./ArchiveBox.conf √ SQL_INDEX 460.0 KB valid ./index.sqlite3 ``` <!-- Tickets without full version info will closed until it is provided, we need the full output here to help you solve your issue -->
Author
Owner

@pirate commented on GitHub (Apr 7, 2021):

I just touched the JS recently which handles sending the tag IDs so it's probably broken from that, will investigate, thanks.

<!-- gh-comment-id:815239521 --> @pirate commented on GitHub (Apr 7, 2021): I just touched the JS recently which handles sending the tag IDs so it's probably broken from that, will investigate, thanks.
Author
Owner

@pirate commented on GitHub (Apr 10, 2021):

Fixed in a9986f1. Try the latest v0.6 build and comment back here if you have any issues and I'll reopen it.

<!-- gh-comment-id:817102339 --> @pirate commented on GitHub (Apr 10, 2021): Fixed in a9986f1. Try the latest v0.6 build and comment back here if you have any issues and I'll reopen it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ArchiveBox#435
No description provided.