fix(analytics): pass datetime to utcoffset() — zoneinfo returns None with bare None arg#24030
Closed
Eji4h wants to merge 1 commit into
Closed
fix(analytics): pass datetime to utcoffset() — zoneinfo returns None with bare None arg#24030Eji4h wants to merge 1 commit into
Eji4h wants to merge 1 commit into
Conversation
…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
This was referenced May 11, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)returnsNone(the bareNoneargument means "no datetime passed in"), which then causesAttributeError: NoneType object has no attribute total_seconds.Fix: Pass
datetime.now()toutcoffset()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 withpytztimezones but not Python stdlibzoneinfo.ZoneInfo.Test Plan
timezone: Asia/Bangkok(or any named zone) in~/.hermes/config.yamlRelated
Closes #23982