Skip to content

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

Closed
Eji4h wants to merge 1 commit into
NousResearch:mainfrom
Eji4h:fix/dashboard-analytics-timezone-23982
Closed

fix(analytics): pass datetime to utcoffset() — zoneinfo returns None with bare None arg#24031
Eji4h wants to merge 1 commit into
NousResearch:mainfrom
Eji4h:fix/dashboard-analytics-timezone-23982

Conversation

@Eji4h

@Eji4h Eji4h commented May 11, 2026

Copy link
Copy Markdown
Contributor

Closes #23982

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)

…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
@Eji4h Eji4h reopened this May 11, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists labels May 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #24030 (same fix, already closed/merged). This PR has the identical title and addresses the same zoneinfo.ZoneInfo.utcoffset(None) regression from #23981.

@Eji4h

Eji4h commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

AI wrong created PR. Please check it again.

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 duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists 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