Skip to content

fix(api): delete only the targeted session - #832

Merged
swolfand merged 1 commit into
mainfrom
codex/linear-mention-mobile-603-spike-session.delete-removes-al
Jul 30, 2026
Merged

fix(api): delete only the targeted session#832
swolfand merged 1 commit into
mainfrom
codex/linear-mention-mobile-603-spike-session.delete-removes-al

Conversation

@swolfand

@swolfand swolfand commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Motivation

  • Session.delete() was documented to delete the receiver session but previously called the client-wide DELETE /client/sessions endpoint and never used the session id, risking removal of all client sessions.

Description

  • Route Session.delete() through the per-session endpoint by calling ClerkApi.session.removeSession(id) and change its return type to ClerkResult<Session, ClerkErrorResponse>.
  • Remove the now-unused Client import from Session.kt that was associated with the bulk delete return type.
  • Add SessionDeleteTest which verifies that removeSession(id) is invoked for the target session ID and that deleteSessions() is not called.

Testing

  • Ran git diff --check to validate changes and code hygiene which reported no issues.
  • Added the unit test com.clerk.api.session.SessionDeleteTest to cover the regression scenario and verify the correct API call.
  • Attempted to run ./gradlew spotlessApply :source:api:testDebugUnitTest --tests 'com.clerk.api.session.SessionDeleteTest' but execution was blocked by the environment missing an Android SDK (ANDROID_HOME/sdk.dir), so the test could not be executed in this environment.

Codex Task

Note

Fix Session.delete to delete only the targeted session instead of all sessions

Session.delete was calling deleteSessions() (DELETE /client/sessions), removing all sessions instead of just the current one. It now calls removeSession(id) with the session's own id and returns a ClerkResult<Session> instead of ClerkResult<Client>. A new test class SessionDeleteTest verifies the correct endpoint is called and deleteSessions() is not invoked.

🖇️ Linked Issues

Resolves MOBILE-603, which identified that Session.delete() was documented to delete the current session but instead called the bulk-delete endpoint.

Macroscope summarized 7c9446f.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected session deletion to remove only the selected session.
    • Updated the deletion result to return the affected session correctly.
  • Tests
    • Added coverage confirming the targeted session is removed and broader session deletion is not triggered.

Route Session.delete through the per-session removal endpoint so deleting one session does not remove every session attached to the client. Add a regression test covering the endpoint and session ID.
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 125b9341-f1de-4439-977d-46bfe5d997f4

📥 Commits

Reviewing files that changed from the base of the PR and between a4f4847 and 7c9446f.

📒 Files selected for processing (2)
  • source/api/src/main/kotlin/com/clerk/api/session/Session.kt
  • source/api/src/test/java/com/clerk/api/session/SessionDeleteTest.kt

📝 Walkthrough

Walkthrough

Session.delete() now removes only the current session, returns ClerkResult<Session, ClerkErrorResponse>, and is covered by a unit test verifying the delegated API call.

Changes

Session deletion correction

Layer / File(s) Summary
Targeted session deletion and validation
source/api/src/main/kotlin/com/clerk/api/session/Session.kt, source/api/src/test/java/com/clerk/api/session/SessionDeleteTest.kt
Session.delete() calls removeSession(id) and returns a session result; the test verifies the result and ensures deleteSessions() is not invoked.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: session deletion now targets only the current session.
Description check ✅ Passed The description covers motivation, implementation, and testing, with enough context for reviewers despite using different headings than the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/linear-mention-mobile-603-spike-session.delete-removes-al

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@swolfand
swolfand marked this pull request as ready for review July 30, 2026 02:49
@swolfand
swolfand merged commit c24f404 into main Jul 30, 2026
17 checks passed
@swolfand
swolfand deleted the codex/linear-mention-mobile-603-spike-session.delete-removes-al branch July 30, 2026 04:36
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.

1 participant