Skip to content

Fix OIDC login crash from naive/aware datetime mismatch#66

Open
hyzyla wants to merge 1 commit into
evo-company:mainfrom
hyzyla:fix-oidc-datetime-mismatch
Open

Fix OIDC login crash from naive/aware datetime mismatch#66
hyzyla wants to merge 1 commit into
evo-company:mainfrom
hyzyla:fix-oidc-datetime-mismatch

Conversation

@hyzyla

@hyzyla hyzyla commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Signing in through OIDC (e.g. Google) returns HTTP 500 on GET /oidc/{provider}/callback:

TypeError: can't compare offset-naive and offset-aware datetimes
  File ".../featureflags/services/auth.py", line 111, in get_access_token
    "exp": min(self.session_exp, datetime.utcnow() + ACCESS_TOKEN_TTL),

Cause. The OIDC callback built the session expiry with an aware datetime (datetime.now(UTC)), while the rest of the auth code uses naive UTC — get_access_token, the LDAP login path (graph/actions.py), and the TIMESTAMP columns. get_access_token then evaluates min(session_exp, datetime.utcnow() + ...), which raises when one operand is aware and the other naive. The OIDC callback was the only place in the codebase creating an aware datetime, so it was the only flow that hit this.

Fix. Use naive datetime.utcnow() in the callback to match the rest of the codebase, and drop the now-unused UTC import. This is consistent with existing usage (DTZ003 is already in the ruff ignore list).

Validated by deploying a patched build to a dev environment: Google login now completes and the session cookie is set.

The OIDC callback created the session expiry as an aware datetime while the rest of the auth code, the LDAP login path and the TIMESTAMP columns use naive UTC. get_access_token then compared them with min(), raising "can't compare offset-naive and offset-aware datetimes" and returning HTTP 500 on the callback. Use naive datetime.utcnow() to match the rest of the codebase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant