[PR #168] fix: use aware UTC in auth and log cutoffs #2635

Open
opened 2026-06-07 15:05:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/reconurge/flowsint/pull/168
Author: @Ghraven
Created: 6/4/2026
Status: 🔄 Open

Base: mainHead: fix-core-aware-utc-auth-log


📝 Commits (1)

  • a8aef7e fix: use aware utc in auth and log cutoffs

📊 Changes

4 files changed (+44 additions, -4 deletions)

View changed files

📝 flowsint-api/tests/test_events_auth.py (+23 -0)
📝 flowsint-core/src/flowsint_core/core/auth.py (+2 -2)
📝 flowsint-core/src/flowsint_core/core/repositories/log_repository.py (+2 -2)
📝 flowsint-core/tests/repositories/test_log_repository.py (+17 -0)

📄 Description

What changed

This replaces the remaining naive UTC timestamp calls in core auth/log paths with timezone-aware UTC timestamps:

  • create_access_token() now builds JWT expiration with datetime.now(timezone.utc)
  • LogRepository.get_by_sketch() now uses a timezone-aware default cutoff for the last 24 hours
  • added focused coverage for the token clock call and the default recent-log filter

Problem

These two paths still used datetime.utcnow(), while nearby service timestamps had already moved to aware UTC values. Keeping these call sites naive can make comparisons and future Python compatibility more brittle.

Before / after

Before:

  • token expiration and default log cutoff used naive UTC datetimes
  • tests did not guard these remaining core paths

After:

  • both paths use explicit timezone.utc
  • token test fails if the implementation falls back to datetime.utcnow()
  • log repository test covers the default cutoff behavior with aware timestamps

Verification

  • python -m py_compile flowsint-core\src\flowsint_core\core\auth.py flowsint-core\src\flowsint_core\core\repositories\log_repository.py flowsint-api\tests\test_events_auth.py flowsint-core\tests\repositories\test_log_repository.py

I also tried:

  • PYTHONPATH=flowsint-core\src;flowsint-api python -m pytest flowsint-api\tests\test_events_auth.py flowsint-core\tests\repositories\test_log_repository.py

but local collection is blocked in this environment by missing passlib before the tests run (ModuleNotFoundError: No module named 'passlib').


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/reconurge/flowsint/pull/168 **Author:** [@Ghraven](https://github.com/Ghraven) **Created:** 6/4/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-core-aware-utc-auth-log` --- ### 📝 Commits (1) - [`a8aef7e`](https://github.com/reconurge/flowsint/commit/a8aef7eda1599996c3ec82958b2b975272609308) fix: use aware utc in auth and log cutoffs ### 📊 Changes **4 files changed** (+44 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `flowsint-api/tests/test_events_auth.py` (+23 -0) 📝 `flowsint-core/src/flowsint_core/core/auth.py` (+2 -2) 📝 `flowsint-core/src/flowsint_core/core/repositories/log_repository.py` (+2 -2) 📝 `flowsint-core/tests/repositories/test_log_repository.py` (+17 -0) </details> ### 📄 Description ## What changed This replaces the remaining naive UTC timestamp calls in core auth/log paths with timezone-aware UTC timestamps: - `create_access_token()` now builds JWT expiration with `datetime.now(timezone.utc)` - `LogRepository.get_by_sketch()` now uses a timezone-aware default cutoff for the last 24 hours - added focused coverage for the token clock call and the default recent-log filter ## Problem These two paths still used `datetime.utcnow()`, while nearby service timestamps had already moved to aware UTC values. Keeping these call sites naive can make comparisons and future Python compatibility more brittle. ## Before / after Before: - token expiration and default log cutoff used naive UTC datetimes - tests did not guard these remaining core paths After: - both paths use explicit `timezone.utc` - token test fails if the implementation falls back to `datetime.utcnow()` - log repository test covers the default cutoff behavior with aware timestamps ## Verification - `python -m py_compile flowsint-core\src\flowsint_core\core\auth.py flowsint-core\src\flowsint_core\core\repositories\log_repository.py flowsint-api\tests\test_events_auth.py flowsint-core\tests\repositories\test_log_repository.py` I also tried: - `PYTHONPATH=flowsint-core\src;flowsint-api python -m pytest flowsint-api\tests\test_events_auth.py flowsint-core\tests\repositories\test_log_repository.py` but local collection is blocked in this environment by missing `passlib` before the tests run (`ModuleNotFoundError: No module named 'passlib'`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-06-07 15:05:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/flowsint#2635