PDF report generation can overwrite HTML when the destination extension is not lowercase .html

Đang mở Phù hợp với người mới
#10,082 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 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
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với việc xác định đường dẫn PDF trong Report/Program.cs và theo dõi cách đích được truyền cho bộ chuyển đổi. Kiểm tra thiết lập kiểm thử hiện có của trình khởi chạy báo cáo để xem có bao phủ hồi quy cho phần mở rộng viết hoa và đường dẫn đầu vào, đầu ra giống hệt nhau hay không. Hoàn thành khi report.HTML vẫn nguyên vẹn, một tệp PDF riêng được tạo và các trường hợp hồi quy vượt qua.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

The report launcher derives the PDF output path with destination.Replace(".html", ".pdf") in Report/Program.cs. With a destination such as report.HTML, the replacement does nothing: wkhtmltopdf receives the same path for its input and output. It overwrites the HTML with PDF content, writes no report.pdf, and exits successfully.

This path derivation is already present on master.

Reproduction

  1. Build the report launcher in Release and install xvfb-run and wkhtmltopdf.

  2. Use Report/config.example.json as config.json, with the report template and CSS available in the working directory.

  3. Point backtest-data-source-file at Tests/TestData/test_report_data.json, set live-data-source-file to an empty string, and set:

    {
      "report-format": "PDF",
      "report-destination": "/tmp/report-repro/report.HTML",
      "close-automatically": true
    }
    
  4. Create /tmp/report-repro and run dotnet /path/to/QuantConnect.Report.dll from the report working directory.

Observed with the real converter: launcher exit code 0; report.HTML starts with %PDF- instead of HTML; report.pdf is absent.

The converter behavior can also be reproduced independently:

mkdir -p /tmp/report-repro
printf '%s\n' '<!doctype html><html><body>Report</body></html>' > /tmp/report-repro/report.HTML
xvfb-run --server-args='-screen 0, 1600x1200x24+32' wkhtmltopdf /tmp/report-repro/report.HTML /tmp/report-repro/report.HTML

Expected

Keep the generated HTML and write a separate PDF alongside it, without allowing the two output paths to coincide. Suggestion: derive the PDF filename with Path.ChangeExtension and add regression coverage for non-lowercase extensions and identical input/output paths.

Ngôn ngữ chính
C#
Star
22.5k
Fork
5.4k
Merge trung bình
22 giờ 6 phút
Pull request đã merge (30 ngày)
81

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của QuantConnect/Lean

Tất cả issue của QuantConnect/Lean

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.