Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

pet server logs warnings as ANSI-colored stderr, shown as errors

Đang mở
#571 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@karthiknadig đang làm issue này rồi.

Từ ngày 5/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

bug

Problem: Since #314, pet server writes its diagnostics as ANSI-colored text on stderr instead of sending log notifications. The VS Code Python Environments extension logs every stderr chunk at error level, so routine warnings show up as [error] lines full of escape codes in the Python Environments output channel.

For example, on a Windows machine with only per-user Python installs, every startup logs:

[error] [pet] ␛[2m   0.008930700s␛[0m ␛[33m WARN␛[0m ␛[2mpet_windows_registry::environments␛[0m␛[2m:␛[0m Failed to open HKLM\Software\Python, Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }

Output channel filtered to [pet]: a WARN line logged as [error], with ESC control characters

These are the first "errors" users and triagers see in logs. Of 33 microsoft/vscode-python-environments issues that quote [error] [pet] lines, 15 include warnings logged this way (as ^[[33m WARN^[[0m), mostly pet_conda::package: Unable to find conda package … and pet_windows_registry::environments: Failed to open HKLM\Software\Python. For example microsoft/vscode-python-environments#1370 (71 such lines), microsoft/vscode-python-environments#1099 and microsoft/vscode-python-environments#1491.

Cause:

Suggested fix:

  • In server mode, forward tracing events as log notifications with their level (a tracing layer that reuses pet_reporter::jsonrpc::Log), and keep stderr for panics.
  • Disable ANSI colors when stderr is not a terminal (.with_ansi(std::io::stderr().is_terminal())).
  • Optionally, in the extension: log stderr by the level token in each line, not as errors.

Environment: Windows 11, VS Code 1.140.0, PET main @ 4ca7c03 with Python Environments main @ 52f6ace.

Steps to verify fix:

  1. On Windows without a machine-wide Python (no HKLM\Software\Python key), open a Python file in VS Code with Python Environments.
  2. Open the Output panel, select Python Environments, and filter by [pet].
  3. Verify the Failed to open HKLM\Software\Python message is logged as [warning] (or not at all at the default level) and contains no ␛[ sequences.
  4. Point python.defaultInterpreterPath at a missing file and reload; verify PET's resolve failure is still logged as [error].
  5. Run pet find 2> err.txt and verify err.txt has no ANSI escape codes.

Found by Copilot

Ngôn ngữ chính
Rust
Star
207
Fork
45
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
18

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.

  • Không có Dockerfile hay tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

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 microsoft/python-environment-tools

Tất cả issue của microsoft/python-environment-tools

Issue tương tự

Thêm issue về Rust

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.