Installation and Bot reject ISO 8601 timestamps with a negative UTC offset or a Z suffix

Đang mở
#1,989 2 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

@hello-ashleyintech đang làm issue này rồi.

Từ ngày 20/10/2026.

  • #1990 của @sebxt — đang mở

Đánh giá

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

Mô tả

auto-triage-stale bug
What happens

Installation, Bot and the token rotation code accept installed_at (and *_token_expires_at) as an ISO 8601 string. Strings with a positive offset parse correctly, but a negative offset or a Z suffix raises ValueError:

from slack_sdk.oauth.installation_store import Installation

Installation(
    user_id="U111",
    installed_at="2021-07-14T03:00:17-05:00",
)
# ValueError: Invalid isoformat string: '2021-07-14T03:00:17-05:00+00:00'

Installation(
    user_id="U111",
    installed_at="2021-07-14T08:00:17Z",
)
# ValueError: Invalid isoformat string: '2021-07-14T08:00:17Z+00:00'  (Python 3.11+)

"2021-07-14T17:00:17+09:00" works, so the result depends on the sign of the offset.

What should happen

Any string datetime.fromisoformat can parse should be accepted. Strings without an offset should keep being treated as UTC.

Root cause

_from_iso_format_to_datetime in slack_sdk/oauth/installation_store/internals.py decides whether a string already has an offset by checking for a + character:

if "+" not in iso_datetime_str:
    iso_datetime_str += "+00:00"
return datetime.fromisoformat(iso_datetime_str)

For -05:00 or Z there is no +, so a second offset is appended and parsing fails. Parsing first and setting UTC only when tzinfo is None fixes it, which matches how naive datetime values are already handled in _timestamp_to_type since #1970.

Ngôn ngữ chính
Python
Star
4k
Fork
874
Merge trung bình
13 giờ 22 phút
Pull request đã merge (30 ngày)
64

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 slackapi/python-slack-sdk

Tất cả issue của slackapi/python-slack-sdk

Issue tương tự

Thêm issue về Python

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.