time: an invalid timezone that names a tzdata directory returns an error with the host's filesystem path

Đang mở Phù hợp với người mới
#5,559 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
76/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ệ
python

Hướng nghiên cứu

Bắt đầu tại src/time/src/mcp_server_time/server.py ở get_zoneinfo, sau đó kiểm tra các bài kiểm thử giao thức cho get_current_time và convert_time. Tái hiện trường hợp thư mục với America và xác minh cả hai công cụ đều trả về lỗi Invalid timezone mà không có đường dẫn hệ thống tệp; kiểm tra để đảm bảo các lỗi múi giờ không xác định vẫn gọn gàng.

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

Mô tả

bug server-time v2

Problem

get_zoneinfo (src/time/src/mcp_server_time/server.py) turns any exception from loading a zone into ToolError(f"Invalid timezone: {e!s}"). For most bad names that is a clean "No time zone found" message, but a name that is a directory in the tz database (for example America) raises an OSError whose text includes the host's absolute path to the tzdata install, e.g.:

Invalid timezone: [Errno 21] Is a directory: '/Users/<user>/.../site-packages/tzdata/zoneinfo/America'

That leaks host filesystem details (including a home-directory user name) into tool output, and it is inconsistent with startup, where serve() already hides these messages.

Expected behavior

An invalid timezone always produces a fixed, clean message naming the input, such as Invalid timezone: America, with no exception text, whatever exception the zone loader raised.

Acceptance criteria

  • get_current_time and convert_time called with a tz-database directory name (America) return a clean Invalid timezone error containing no filesystem path.
  • Existing error messages for unknown names are unchanged or equally clean.
  • Tests cover the directory case at the protocol level.
Ngôn ngữ chính
TypeScript
Star
92k
Fork
12k
Merge trung bình
3 giờ 12 phút
Pull request đã merge (30 ngày)
174

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

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 modelcontextprotocol/servers

Tất cả issue của modelcontextprotocol/servers

Issue tương tự

Thêm issue về TypeScript

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.