Skip to content

refactor(api)!: remove Session.hasMaximumLifetime - #1166

Closed
swolfand wants to merge 1 commit into
mainfrom
sam/drop-has-maximum-lifetime
Closed

swolfand wants to merge 1 commit into
mainfrom
sam/drop-has-maximum-lifetime

Conversation

@swolfand

@swolfand swolfand commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

What & why

Breaking change: this removes Session.hasMaximumLifetime, which shipped in 1.3.0 (#960). To tell whether a session has a maximum lifetime, check session.expireAt == 0L. Zero means no maximum lifetime.

This matches iOS, where clerk/clerk-ios#576 added no new API and pinned zero deadlines with tests and doc comments. The SDKs will not expose hasMaximumLifetime, so Android drops it too.

  • Session.hasMaximumLifetime and its api.api entry are gone.
  • The KDoc on expireAt says zero (the Unix epoch) means no maximum lifetime. A response that omits expire_at or sends null still decodes as zero.
  • The KDoc on abandonAt says zero means no abandonment deadline.
  • SessionLifetimeTest now asserts the deadlines directly, mirroring iOS's SessionLifetimeTests:
    • zero expire_at and abandon_at decode as 0L on an active session;
    • a revoked session keeps zero deadlines;
    • a missing or null expire_at decodes as zero;
    • zero deadlines survive a round trip through CachedClerkState, the client cache codec that ClientStateStore.save uses. ClerkApi.json does not encode defaults, so the cache omits expire_at (its default is 0L) and writes abandon_at as 0. Both restore as 0L.

Nothing in the SDK compares Session.expireAt with the current time, so a zero deadline is never treated as expired. Token refresh uses the session token's own expiry.

Part of MOBILE-517. Companions: clerk/clerk-ios#576, #960, clerk/javascript#9871.

Release notes

Under Breaking changes: Session.hasMaximumLifetime is removed. Use session.expireAt == 0L to detect a session with no maximum lifetime.

Screenshots / video

No UI changes. Not run on a device. This machine has no Clerk Platform API key for the verification workspace, and the verify skill needs one to create the test instance, locally or on a CI runner. The change removes a getter that nothing in the SDK or the :e2e host calls and rewords KDoc, so no runtime behavior changes. The unit tests above cover the decoding and cached-client paths that zero deadlines take.

Checked locally: spotlessCheck, detekt, :source:api:detektDebug, :source:api:lint, :source:api:testDebugUnitTest, and apiCheck.

Summary by CodeRabbit

  • Behavior Updates
    • Session expiration and abandonment timestamps of zero are now consistently treated as the Unix epoch, including for revoked sessions.
    • Sessions with omitted or null expiration timestamps decode with a value of zero. Zero timestamp values are preserved when sessions are cached and restored.
  • API Changes
    • Removed the public hasMaximumLifetime session property.

Match clerk-ios#576: the SDKs expose no session-lifetime API. A session with no maximum lifetime has expireAt == 0L. Document that zero means no deadline on expireAt and abandonAt, and assert zero deadlines directly, including for revoked sessions and through the cached client codec.

BREAKING CHANGE: Session.hasMaximumLifetime, added in 1.3.0, is removed. Check expireAt == 0L instead.

Part of MOBILE-517
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between dda01a7 and eca492f.

📒 Files selected for processing: 3
  • source/api/api/api.api
  • source/api/src/main/kotlin/com/clerk/api/session/Session.kt
  • source/api/src/test/java/com/clerk/api/session/SessionLifetimeTest.kt
💤 Files with no reviewable changes: 1
  • source/api/api/api.api

Included review availability: This review used your included allowance. 5 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour.

📝 Walkthrough

The public Session API no longer exposes hasMaximumLifetime. Deadline documentation defines zero as the Unix epoch. Tests verify zero deadlines for active and revoked sessions and across cached-state serialization.

Changes: Session deadline semantics

Layer / File(s) Summary
Session deadline contract and serialization
source/api/api/api.api, source/api/src/main/kotlin/com/clerk/api/session/Session.kt, source/api/src/test/java/com/clerk/api/session/SessionLifetimeTest.kt
Removes the public maximum-lifetime property and updates deadline documentation. Tests check zero deadlines for active and revoked sessions, and verify their values in a cached-state serialization round trip.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: mikepitre

Merge Risk: ⚪ Minimal · up to eca49

The documented replacement for the removed property is consistent with the zero-deadline behavior. No identified issue blocks merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main breaking change: removal of Session.hasMaximumLifetime.
Description check Passed The description is complete and relevant. It explains why the API is removed, documents the replacement guidance, summarizes tests and risks, includes release-note guidance, and addresses screenshots …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is complete and relevant. It explains why the API is removed, documents the replacement guidance, summarizes tests and risks, includes release-note guidance, and addresses screenshots and device verification. The required sections are substantially covered.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@swolfand
swolfand marked this pull request as ready for review October 22, 2026 19:00
@swolfand
swolfand enabled auto-merge (squash) October 22, 2026 19:01
@swolfand

Copy link
Copy Markdown
Collaborator Author

Closing as superseded: #1165 already removed Session.hasMaximumLifetime from main, and #1175 drops the zero-deadline docs and tests now that the backend gives indefinite native sessions a real far-future deadline.

@swolfand swolfand closed this Oct 23, 2026
auto-merge was automatically disabled October 23, 2026 17:04

Pull request was closed

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