Skip to content

fix: return ISO8601 session expire from updateSession - #12891

Merged
Meldiron merged 2 commits into
appwrite:mainfrom
cipheraxat:fix-8447-session-expire-format
Aug 3, 2026
Merged

Meldiron merged 2 commits into
appwrite:mainfrom
cipheraxat:fix-8447-session-expire-format

Conversation

@cipheraxat

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #8447 by wrapping expire and providerAccessTokenExpiry with DateTime::formatTz() in PATCH /v1/account/sessions/:sessionId.

Previously, updateSession returned the DB datetime format (Y-m-d H:i:s.v) from DateTime::addSeconds(), while GET session returned ISO8601 via the datetime decode filter. Create-session paths already used formatTz; this aligns update with that pattern so SDK clients can deserialize expire consistently.

Test Plan

  • Updated testRefreshEmailPasswordSession to assert PATCH (and subsequent GET) expire is ISO8601 via DatetimeValidator and Y-m-d\TH:i:s.uP
  • Ran locally: docker compose exec appwrite vendor/bin/phpunit --filter testRefreshEmailPasswordSession (passed)

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Wrap expire and providerAccessTokenExpiry with DateTime::formatTz so PATCH /account/sessions matches GET and create-session responses (appwrite#8447).
@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes an inconsistency in the PATCH /v1/account/sessions/:sessionId (updateSession) endpoint where expire and providerAccessTokenExpiry were returned in the internal DB datetime format (Y-m-d H:i:s.v) rather than ISO8601, unlike GET session and all create-session paths.

  • Core fix (account.php): Both setAttribute('expire', ...) and setAttribute('providerAccessTokenExpiry', ...) in the PATCH handler now wrap DateTime::addSeconds() with DateTime::formatTz(), matching the pattern already used everywhere else in the file.
  • Tests (AccountCustomClientTest.php): testRefreshEmailPasswordSession now asserts that the PATCH response and the follow-up GET both contain an ISO8601-formatted expire value, using both DatetimeValidator and DateTime::createFromFormat('Y-m-d\\TH:i:s.uP', ...).

Confidence Score: 5/5

Safe to merge — the change is a targeted two-line fix that aligns the update path with the already-established create-session pattern throughout the same file.

Both changed lines follow the exact same DateTime::formatTz(DateTime::addSeconds(...)) idiom used by every other session-creation path in account.php. The accompanying test explicitly validates the ISO8601 format for both the PATCH response and the subsequent GET.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
app/controllers/api/account.php Wraps expire and providerAccessTokenExpiry with DateTime::formatTz() in the PATCH handler, aligning the update path with the ISO8601 format already used by create-session paths.
tests/e2e/Services/Account/AccountCustomClientTest.php Adds DatetimeValidator and DateTime::createFromFormat assertions to verify the PATCH response and subsequent GET both return ISO8601-formatted expire.

Reviews (2): Last reviewed commit: "Merge branch 'main' into fix-8447-sessio..." | Re-trigger Greptile

@Meldiron
Meldiron merged commit 100f5e1 into appwrite:main Aug 3, 2026
43 checks passed
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.

🐛 Bug Report: Session - Expire property format returned is inconsistent

2 participants