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

Offen
#1,989 2 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@hello-ashleyintech arbeitet bereits daran.

Seit 20.10.2026.

  • #1990 von @sebxt — offen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
4k
Forks
874
Ø Merge
13 Std. 22 Min.
Gemergte PRs (30 T.)
64

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus slackapi/python-slack-sdk

Alle Issues in slackapi/python-slack-sdk

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.