Skip to content

fix(analytics): pass datetime to utcoffset() — zoneinfo returns None with bare None arg#24030

Closed
Eji4h wants to merge 1 commit into
NousResearch:mainfrom
Eji4h:main
Closed

fix(analytics): pass datetime to utcoffset() — zoneinfo returns None with bare None arg#24030
Eji4h wants to merge 1 commit into
NousResearch:mainfrom
Eji4h:main

Conversation

@Eji4h

@Eji4h Eji4h commented May 11, 2026

Copy link
Copy Markdown

Description

Fixed a crash in the dashboard analytics endpoint (GET /api/analytics/usage) when the user has a non-UTC timezone configured.

Root cause: zoneinfo.ZoneInfo("Asia/Bangkok").utcoffset(None) returns None (the bare None argument means "no datetime passed in"), which then causes AttributeError: NoneType object has no attribute total_seconds.

Fix: Pass datetime.now() to utcoffset() so the zoneinfo object can compute the actual UTC offset for the current time.

This was a regression from #23981 which introduced the timezone offset logic but used utcoffset(None) — works with pytz timezones but not Python stdlib zoneinfo.ZoneInfo.

Test Plan

  1. Set timezone: Asia/Bangkok (or any named zone) in ~/.hermes/config.yaml
  2. Open Dashboard → Analytics tab
  3. Before: ❌ 500 Internal Server Error
  4. After: ✅ Daily usage chart shows data grouped by Bangkok (not UTC)

Related

Closes #23982

…with bare None arg

zoneinfo.ZoneInfo('Asia/Bangkok').utcoffset(None) returns None, crashing
get_usage_analytics with AttributeError. Pass datetime.now() instead so
the configured timezone offset is correctly computed.

Fixes NousResearch#23982
@Eji4h Eji4h closed this May 11, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard labels May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard analytics daily chart uses UTC instead of configured timezone

2 participants