Skip to content

fix: use timezone-aware dates for token queries - #9926

Open
lprnmns wants to merge 1 commit into
HumanSignal:developfrom
lprnmns:codex/fix-jwt-aware-time
Open

lprnmns wants to merge 1 commit into
HumanSignal:developfrom
lprnmns:codex/fix-jwt-aware-time

Conversation

@lprnmns

@lprnmns lprnmns commented Sep 4, 2026

Copy link
Copy Markdown

Description

Fixes #9716.

Token listing filtered Django DateTimeFields with naive datetime.now() values while timezone support is enabled. An authenticated GET /api/token/ consequently emitted two RuntimeWarnings.

Use Django's timezone-aware clock for both expiry filters. The behavior and response shape are otherwise unchanged.

Tests

  • DJANGO_DB=sqlite uv run --frozen --group test pytest label_studio/tests/jwt_auth/test_views.py -q — 8 passed
  • DJANGO_DB=sqlite uv run --frozen --group test pytest label_studio/tests/jwt_auth -q — 26 passed
  • uv run --frozen --group test pre-commit run --hook-stage pre-push --files label_studio/jwt_auth/views.py label_studio/tests/jwt_auth/test_views.py — Ruff lint and format passed

Acceptance criterion: when an authenticated user lists API tokens with timezone support enabled, the endpoint returns 200 without a naive-datetime warning.

Risk is low: only the source of the current timestamp changes, from server-local naive time to Django's configured timezone-aware time.

Use Django's timezone-aware clock when filtering outstanding tokens so token list requests do not emit naive datetime warnings under USE_TZ.

Refs HumanSignal#9716
@netlify

netlify Bot commented Sep 4, 2026

Copy link
Copy Markdown

👷 Deploy request for heartex-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 9398e57

@netlify

netlify Bot commented Sep 4, 2026

Copy link
Copy Markdown

👷 Deploy request for label-studio-docs-new-theme pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 9398e57

@netlify

netlify Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deploy Preview for label-studio-storybook canceled.

Name Link
🔨 Latest commit 9398e57
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/6a9afb842000880009e95a25

@netlify

netlify Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deploy Preview for label-studio-playground canceled.

Name Link
🔨 Latest commit 9398e57
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/6a9afb84d50e4b000828c91d

@github-actions github-actions Bot added the fix label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Naive datetime on OutstandingToken.expires_at triggers Django warning on GET /api/token

1 participant