[GH-ISSUE #857] Bug: 500 error when attempting to sort by size #529

Closed
opened 2026-03-01 14:44:21 +03:00 by kerem · 3 comments
Owner

Originally created by @WesleyAC on GitHub (Sep 26, 2021).
Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/857

Steps to reproduce

  1. Go to http://localhost:8000/admin/core/snapshot/
  2. Click the "SIZE" header
  3. This redirects to http://localhost:8000/admin/core/snapshot/?o=4.-1, which reports "Server Error (500)"

Screenshots or log output

"GET /admin/core/snapshot/?o=4.-1 HTTP/1.1" 500 145
"GET /admin/core/snapshot/ HTTP/1.1" 200 105692
Internal Server Error: /admin/core/snapshot/
Traceback (most recent call last):
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/contrib/admin/options.py", line 614, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 233, in inner
    return view(request, *args, **kwargs)
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1811, in changelist_view
    'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/query.py", line 269, in __len__
    self._fetch_all()
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/query.py", line 1308, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1143, in execute_sql
    sql, params = self.as_sql()
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 498, in as_sql
    extra_select, order_by, group_by = self.pre_sql_setup()
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 56, in pre_sql_setup
    order_by = self.get_order_by()
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 346, in get_order_by
    order_by.extend(self.find_ordering_name(
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 747, in find_ordering_name
    return [(OrderBy(transform_function(t, alias), descending=descending), False) for t in targets]
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 747, in <listcomp>
    return [(OrderBy(transform_function(t, alias), descending=descending), False) for t in targets]
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1584, in transform
    return self.try_transform(wrapped, name)
  File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1198, in try_transform
    raise FieldError(
django.core.exceptions.FieldError: Unsupported lookup 'count' for AutoField or join on the field not permitted, perhaps you meant contains?

ArchiveBox version

ArchiveBox v0.6.2
Cpython Linux Linux-5.10.66-x86_64-with-glibc2.33 x86_64
IN_DOCKER=False DEBUG=False IS_TTY=True TZ=UTC SEARCH_BACKEND_ENGINE=ripgrep

[i] Dependency versions:
 √  ARCHIVEBOX_BINARY     v0.6.2          valid     /nix/store/xfqwr74qli0fm186dj5006960mn5pw38-archivebox-0.6.2/bin/archivebox 
 √  PYTHON_BINARY         v3.9.6          valid     /nix/store/i1m8r7mv8h47wr850cdsxksy22lv6gsz-python3-3.9.6/bin/python3.9     
 √  DJANGO_BINARY         v3.1.7          valid     /nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/bin/django-admin.py
 √  CURL_BINARY           v7.76.1         valid     /nix/store/blaac45yvgljsy15jdxgvxxqs6w5yhqj-curl-7.76.1-bin/bin/curl        
 -  WGET_BINARY           -               disabled  /run/current-system/sw/bin/wget                                             
 √  NODE_BINARY           v14.17.6        valid     /nix/store/zqgmd79n5p0mdaw4sbvkv7gvrmks76a2-nodejs-14.17.6/bin/node         
 √  SINGLEFILE_BINARY     v0.3.31         valid     ./node_modules/single-file/cli/single-file                                  
 √  READABILITY_BINARY    v0.0.3          valid     ./node_modules/readability-extractor/readability-extractor                  
 √  MERCURY_BINARY        v1.0.0          valid     ./node_modules/@postlight/mercury-parser/cli.js                             
 -  GIT_BINARY            -               disabled  /run/current-system/sw/bin/git                                              
 -  YOUTUBEDL_BINARY      -               disabled  /nix/store/vmfzdc3wrnhhklk8fm5zrz342vp9kwd4-python3.9-youtube-dl-2021.06.06/bin/youtube-dl
 √  CHROME_BINARY         v93.0.4577.82   valid     /run/current-system/sw/bin/chromium-browser                                 
 √  RIPGREP_BINARY        v12.1.1         valid     /run/current-system/sw/bin/rg                                               

[i] Source-code locations:
 √  PACKAGE_DIR           23 files        valid     /nix/store/xfqwr74qli0fm186dj5006960mn5pw38-archivebox-0.6.2/lib/python3.9/site-packages/archivebox
 √  TEMPLATES_DIR         3 files         valid     /nix/store/xfqwr74qli0fm186dj5006960mn5pw38-archivebox-0.6.2/lib/python3.9/site-packages/archivebox/templates
 -  CUSTOM_TEMPLATES_DIR  -               disabled                                                                              

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

[i] Data locations:
 √  OUTPUT_DIR            6 files         valid     /home/wesleyac/code/notebook/data/archivebox                                
 √  SOURCES_DIR           186 files       valid     ./sources                                                                   
 √  LOGS_DIR              1 files         valid     ./logs                                                                      
 √  ARCHIVE_DIR           166 files       valid     ./archive                                                                   
 √  CONFIG_FILE           246.0 Bytes     valid     ./ArchiveBox.conf                                                           
 √  SQL_INDEX             1.4 MB          valid     ./index.sqlite3                                                             
Originally created by @WesleyAC on GitHub (Sep 26, 2021). Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/857 #### Steps to reproduce 1. Go to http://localhost:8000/admin/core/snapshot/ 2. Click the "SIZE" header 3. This redirects to http://localhost:8000/admin/core/snapshot/?o=4.-1, which reports "Server Error (500)" #### Screenshots or log output ``` "GET /admin/core/snapshot/?o=4.-1 HTTP/1.1" 500 145 "GET /admin/core/snapshot/ HTTP/1.1" 200 105692 Internal Server Error: /admin/core/snapshot/ Traceback (most recent call last): File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/contrib/admin/options.py", line 614, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 233, in inner return view(request, *args, **kwargs) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper return bound_method(*args, **kwargs) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1811, in changelist_view 'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)}, File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/query.py", line 269, in __len__ self._fetch_all() File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/query.py", line 1308, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/query.py", line 53, in __iter__ results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1143, in execute_sql sql, params = self.as_sql() File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 498, in as_sql extra_select, order_by, group_by = self.pre_sql_setup() File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 56, in pre_sql_setup order_by = self.get_order_by() File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 346, in get_order_by order_by.extend(self.find_ordering_name( File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 747, in find_ordering_name return [(OrderBy(transform_function(t, alias), descending=descending), False) for t in targets] File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 747, in <listcomp> return [(OrderBy(transform_function(t, alias), descending=descending), False) for t in targets] File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1584, in transform return self.try_transform(wrapped, name) File "/nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1198, in try_transform raise FieldError( django.core.exceptions.FieldError: Unsupported lookup 'count' for AutoField or join on the field not permitted, perhaps you meant contains? ``` #### ArchiveBox version <!-- Run the `archivebox version` command locally then copy paste the result here: --> ```logs ArchiveBox v0.6.2 Cpython Linux Linux-5.10.66-x86_64-with-glibc2.33 x86_64 IN_DOCKER=False DEBUG=False IS_TTY=True TZ=UTC SEARCH_BACKEND_ENGINE=ripgrep [i] Dependency versions: √ ARCHIVEBOX_BINARY v0.6.2 valid /nix/store/xfqwr74qli0fm186dj5006960mn5pw38-archivebox-0.6.2/bin/archivebox √ PYTHON_BINARY v3.9.6 valid /nix/store/i1m8r7mv8h47wr850cdsxksy22lv6gsz-python3-3.9.6/bin/python3.9 √ DJANGO_BINARY v3.1.7 valid /nix/store/889dn8m5c562vy949frmxdna4kxfm8rf-python3.9-Django-3.1.7/lib/python3.9/site-packages/django/bin/django-admin.py √ CURL_BINARY v7.76.1 valid /nix/store/blaac45yvgljsy15jdxgvxxqs6w5yhqj-curl-7.76.1-bin/bin/curl - WGET_BINARY - disabled /run/current-system/sw/bin/wget √ NODE_BINARY v14.17.6 valid /nix/store/zqgmd79n5p0mdaw4sbvkv7gvrmks76a2-nodejs-14.17.6/bin/node √ SINGLEFILE_BINARY v0.3.31 valid ./node_modules/single-file/cli/single-file √ READABILITY_BINARY v0.0.3 valid ./node_modules/readability-extractor/readability-extractor √ MERCURY_BINARY v1.0.0 valid ./node_modules/@postlight/mercury-parser/cli.js - GIT_BINARY - disabled /run/current-system/sw/bin/git - YOUTUBEDL_BINARY - disabled /nix/store/vmfzdc3wrnhhklk8fm5zrz342vp9kwd4-python3.9-youtube-dl-2021.06.06/bin/youtube-dl √ CHROME_BINARY v93.0.4577.82 valid /run/current-system/sw/bin/chromium-browser √ RIPGREP_BINARY v12.1.1 valid /run/current-system/sw/bin/rg [i] Source-code locations: √ PACKAGE_DIR 23 files valid /nix/store/xfqwr74qli0fm186dj5006960mn5pw38-archivebox-0.6.2/lib/python3.9/site-packages/archivebox √ TEMPLATES_DIR 3 files valid /nix/store/xfqwr74qli0fm186dj5006960mn5pw38-archivebox-0.6.2/lib/python3.9/site-packages/archivebox/templates - CUSTOM_TEMPLATES_DIR - disabled [i] Secrets locations: - CHROME_USER_DATA_DIR - disabled - COOKIES_FILE - disabled [i] Data locations: √ OUTPUT_DIR 6 files valid /home/wesleyac/code/notebook/data/archivebox √ SOURCES_DIR 186 files valid ./sources √ LOGS_DIR 1 files valid ./logs √ ARCHIVE_DIR 166 files valid ./archive √ CONFIG_FILE 246.0 Bytes valid ./ArchiveBox.conf √ SQL_INDEX 1.4 MB 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 -->
kerem closed this issue 2026-03-01 14:44:21 +03:00
Author
Owner

@pirate commented on GitHub (Sep 27, 2021):

Yeah I haven't implemented sorting by size, so I'm not surprised it's failing. I might just remove the sort ability for now, as it's not an easy problem (size is not a DB column, it's computed lazily and cached).

<!-- gh-comment-id:928424068 --> @pirate commented on GitHub (Sep 27, 2021): Yeah I haven't implemented sorting by size, so I'm not surprised it's failing. I might just remove the sort ability for now, as it's not an easy problem (size is not a DB column, it's computed lazily and cached).
Author
Owner

@WesleyAC commented on GitHub (Sep 28, 2021):

Makes sense. Sorting by size would be nice, but it's not hard to du -s archive/* | sort -g, so I don't really mind not having it much — it'd be better for it to be disabled than 500 :)

<!-- gh-comment-id:929483546 --> @WesleyAC commented on GitHub (Sep 28, 2021): Makes sense. Sorting by size would be nice, but it's not hard to `du -s archive/* | sort -g`, so I don't really mind not having it much — it'd be better for it to be disabled than 500 :)
Author
Owner

@pirate commented on GitHub (Jan 19, 2024):

Fixed in 861d44da98. Will be released in v0.7.3

The new behavior is to just sort by number of archive results, since size is still not a db column at the moment.

<!-- gh-comment-id:1900172192 --> @pirate commented on GitHub (Jan 19, 2024): Fixed in 861d44da98feebb49b4e85ea02e306f08a4a0f4f. Will be released in v0.7.3 The new behavior is to just sort by number of archive results, since size is still not a db column at the moment.
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#529
No description provided.