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

Aperta
#1,989 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@hello-ashleyintech ci sta già lavorando.

Dal 20/10/2026.

  • #1990 di @sebxt — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
Python
Stelle
4k
Fork
874
Merge medio
13h 22m
PR unite (30g)
64

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di slackapi/python-slack-sdk

Tutte le issue di slackapi/python-slack-sdk

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.