System settings: Download tab fails with int() argument must be ... not 'NoneType' - spices server serves JSON without Content-Length
Maintainer thường phản hồi trong vòng 8 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
Read files/usr/share/cinnamon/cinnamon-settings/bin/Spices.py, focusing on _url_retrieve() and _update_progress(), then reproduce the Download tab failure with a chunked response that has no Content-Length header. The issue provides the specific changes and reports that fetching applet index.json and thumbnails succeeds afterward; check whether this 6.6.x fix is still needed, since the issue says master was rewritten and is unaffected.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Opening the "Download" tab in System Settings -> Applets (also Desklets, Extensions, Actions, Themes) shows an error dialog:
An error occurred while trying to access the server. Please try again in a little while.
Details: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
The list of available spices can never be loaded - ~/.cache/cinnamon/spices/<type>/index.json stays empty (the partially downloaded file is removed on error).
Reproduce
- cinnamon-settings -> Applets -> Download tab (this triggers
refresh_cache()). - Observe that the request to
cinnamon-spices.linuxmint.com/json/applets.jsonhas noContent-Lengthheader when made through requests/urllib3:
curl -sS -D - -o /dev/null "https://cinnamon-spices.linuxmint.com/json/applets.json" | grep -iE 'HTTP/|content-length|transfer-encoding'
# HTTP/2 200 ... (HEAD reports content-length)
python3 -c "
import requests
r = requests.get('https://cinnamon-spices.linuxmint.com/json/applets.json', stream=True)
print(r.status_code, r.headers.get('content-length'), r.headers.get('transfer-encoding'))"
# 200 None chunked <-- no content-length when requested with Accept-Encoding: gzip
The server now serves the JSON indexes with Transfer-Encoding: chunked + Content-Encoding: gzip, so the content-length header is absent.
Root cause
files/usr/share/cinnamon/cinnamon-settings/bin/Spices.py:
def _url_retrieve(self, url, outfd, reporthook, binary):
...
response = requests.get(url, proxies=proxy_info, stream=True, timeout=15)
assert response.ok
totalSize = int(response.headers.get('content-length')) # <-- None -> TypeError
The exception is caught in _download() and surfaced as "An error occurred while trying to access the server...".
Fix
--- a/files/usr/share/cinnamon/cinnamon-settings/bin/Spices.py
+++ b/files/usr/share/cinnamon/cinnamon-settings/bin/Spices.py
@@ -420,7 +420,8 @@ class Spice_Harvester(GObject.Object):
response = requests.get(url, proxies=proxy_info, stream=True, timeout=15)
assert response.ok
- totalSize = int(response.headers.get('content-length'))
+ content_length = response.headers.get('content-length')
+ totalSize = int(content_length) if content_length is not None else 0
for data in response.iter_content(chunk_size=blockSize):
Plus a guard in _update_progress so the progress bar does not run away when the total size is unknown:
@@ -328,7 +328,12 @@
text = _("Downloading images:") + f" {current}/{total}"
self._set_progressbar_text(text)
else:
- fraction = count * blockSize / float((totalSize / blockSize + 1) * blockSize)
+ if totalSize > 0:
+ fraction = count * blockSize / float((totalSize / blockSize + 1) * blockSize)
+ else:
+ # No content-length header (chunked response) - fall back to a
+ # progress estimate based on the number of chunks received.
+ fraction = count / float(count + 1)
self._set_progressbar_fraction(fraction)
Verification with the patched code: the real Spice_Harvester('applet').refresh_cache() downloads index.json (275 applets, 674698 bytes) plus all thumbnails without errors. Static assets (icons/screenshots) are still served with Content-Length - only the JSON index downloads break.
Environment
- Cinnamon 6.6.7 (Gentoo Linux), Python 3.14, requests 2.34.2 / urllib3 2.7.0
Note
In master, Spices.py was rewritten on top of cinnamon.harvester (non-streamed requests), which is not affected. Suggest backporting the fix to 6.6.x, otherwise this can be closed as fixed-in-master.
- Ngôn ngữ chính
- JavaScript
- Star
- 5.7k
- Fork
- 941
- Merge trung bình
- 6 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của linuxmint/cinnamon
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 8 ngày
-
BUG
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 8 ngày
-
Sound applet: seek bar jumps back after seeking when player resends metadata (e.g. mpDris2/MPD)Đang mởBUG
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 8 ngày
-
Menu applet omits descriptions from search-provider resultsCó thể đã có người làm @ah682 đã nhận 9 ngày trước. Đang mởBUG
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
linuxmint/cinnamon#14104 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 8 ngày
-
xapp-status applet: status icon labels are ellipsized to "..." when the panel zone is a fraction of a pixel shortCó thể làm lại được @Priyeshshrivastav đã nhận 15 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
linuxmint/cinnamon#14096 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 8 ngày
Tất cả issue của linuxmint/cinnamon
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
mailcow/mailcow-dockerized#7677 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
gcivil-nyu-org/team5-mon-fall26#145 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
needs discussion
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openfga/openfga.dev#1436 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày