Skip to content

fix: change last used date encoding#7925

Merged
n1ru4l merged 2 commits intomainfrom
fix-legacy-token-last-used-at
Mar 27, 2026
Merged

fix: change last used date encoding#7925
n1ru4l merged 2 commits intomainfrom
fix-legacy-token-last-used-at

Conversation

@n1ru4l
Copy link
Copy Markdown
Contributor

@n1ru4l n1ru4l commented Mar 27, 2026

Background

This one slipped QA on #7887

It did not get caught by a integration test as the token is cached in redis after creation. This test case creates the database record using the database directly, to simulate the read of a non-cached access token.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the tokenFields query in the legacy storage module to wrap the last_used_at field in a to_json call. Feedback suggests reverting this and the existing to_json for created_at, recommending that timestamp parsing be handled via Zod coercion in the model layer instead. This aligns with the architectural goal of moving logic out of the legacy storage package and ensuring robust data handling.

Comment on lines 23 to +24
, to_json("created_at") AS "date"
, "last_used_at" AS "lastUsedAt"
, to_json("last_used_at") AS "lastUsedAt"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

New database interaction logic should be encapsulated in smaller classes within the corresponding GraphQL modules, not added to the legacy /packages/services/storage module. Additionally, using z.coerce.date() in the TokenModel is a more robust approach for handling timestamps. Note that the database driver returns timestamps as Unix timestamp numbers in milliseconds, so Zod coercion is appropriate to ensure they are treated as Date objects.

Suggested change
, to_json("created_at") AS "date"
, "last_used_at" AS "lastUsedAt"
, to_json("last_used_at") AS "lastUsedAt"
, "created_at" AS "date"
, "last_used_at" AS "lastUsedAt"
References
  1. New database interaction logic should be encapsulated in smaller classes within the corresponding GraphQL modules, not added to the legacy /packages/services/storage module.
  2. The database driver returns timestamps as Unix timestamp numbers in milliseconds, not seconds.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

🐋 This PR was built and pushed to the following Docker images:

Targets: build

Platforms: linux/amd64

Image Tag: 838dd4e161fdcd6e08df3d115968549536238aab

@n1ru4l n1ru4l marked this pull request as ready for review March 27, 2026 13:31
@n1ru4l n1ru4l merged commit 12c990c into main Mar 27, 2026
25 checks passed
@n1ru4l n1ru4l deleted the fix-legacy-token-last-used-at branch March 27, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant