Skip to content

fix: use aware UTC in auth and log cutoffs#168

Open
Ghraven wants to merge 1 commit into
reconurge:mainfrom
Ghraven:fix-core-aware-utc-auth-log
Open

fix: use aware UTC in auth and log cutoffs#168
Ghraven wants to merge 1 commit into
reconurge:mainfrom
Ghraven:fix-core-aware-utc-auth-log

Conversation

@Ghraven

@Ghraven Ghraven commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

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').

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