Keep the market-hours database when a refresh returns malformed JSON
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Read lean/components/cloud/data_downloader.py and lean/components/util/market_hours_database.py to trace the download, file replacement, refresh timestamp, and JSON reader behavior. Check the existing tests for these components, then add the described regression case with a valid cached database and malformed response. Done means invalid content leaves the prior database usable and refresh is recorded only after a successful update. An open linked pull request (#710) is already against this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
On master (d812d26), a successful HTTP response containing malformed JSON can overwrite a usable local market-hours database. Subsequent database reads fail instead of retaining the last valid data.
The path is:
DataDownloader.update_database_files()(lean/components/cloud/data_downloader.py:83-92) downloads the market-hours database and passes its bytes directly to_store_local_file.DataClient.download_public_file()(lean/components/api/data_client.py:89-95) returns raw response content, without JSON validation._store_local_file()(lean/components/cloud/data_downloader.py:24-27) opens the existing file withwb+and writes those bytes.MarketHoursDatabase._get_all_entries()(lean/components/util/market_hours_database.py:63-69) only parses the JSON when it is later read.
The refresh timestamp is also recorded before the download/write (data_downloader.py:85), so a malformed successful response can leave the bad file in place until the next configured refresh interval.
Synthetic reproduction
With the CLI installed and initialized, this uses only a temporary file, not an actual data directory:
import json
import tempfile
from pathlib import Path
from lean.components.cloud.data_downloader import _store_local_file
with tempfile.TemporaryDirectory() as directory:
cache = Path(directory) / "market-hours-database.json"
previous = '{"entries": {}}'
cache.write_text(previous, encoding="utf-8")
# Bytes returned by a malformed HTTP 200 response.
_store_local_file(b"not json", cache)
print(cache.read_text(encoding="utf-8")) # not json; valid data is lost
json.loads(cache.read_text(encoding="utf-8")) # JSONDecodeError
I verified the same result using the isolated _store_local_file function from master: the file becomes not json, and the next decode raises JSONDecodeError. This is a synthetic malformed response, not a report that the hosted database is currently malformed.
Suggested fix
Validate the downloaded market-hours content using the format accepted by its reader (including supported comments and the required entries structure) before replacing the local file. Write through a temporary file, preserve the existing file's access metadata, and replace only after validation and writing succeed. Record a successful refresh only after it completes. Add a regression test with a pre-existing valid database and a malformed successful response.
- Ngôn ngữ chính
- Python
- Star
- 330
- Fork
- 171
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 18
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 QuantConnect/lean-cli
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
QuantConnect/lean-cli#706 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
OAuth: non-interactive deployment discards a valid saved account when multiple accounts are authorizedCó thể đã có người làm @pcbeingused333 đã nhận hôm nay. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 62/100
QuantConnect/lean-cli#699 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
cloud pull --encrypt leaves the project without its key path and encrypts referenced librariesCó thể đã có người làm @Amadeus-22 đã nhận 6 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
QuantConnect/lean-cli#688 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
QuantConnect/lean-cli#681 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
QuantConnect/lean-cli#619 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của QuantConnect/lean-cli
Issue tương tự
-
fuzz fuzz-unconfirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
neilsh/stunt-reel#220 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Issue]: use_fp4_cache is accepted but ignored; the launcher always writes FP8 recordsCó thể đã có người làm @0z5a đã nhận hôm nay. Đang mở
Độ 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 1 ngày
-
area: cli priority: p3 size: S type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
finos/open-resource-broker#757 ·
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 65/100
Maintainer thường phản hồi trong vòng 6 ngày