Repository navigation
fix(api): fix deletePassword and revokeSession, which threw on first call - #997
Conversation
…call UserApi.deletePassword had a bare @post, so Retrofit threw "Missing either @post URL or @url parameter." the first time User.deletePassword() ran. Point it at ApiPaths.User.Password.DELETE (POST me/remove_password). SessionApi.revokeSession declared its @query before its @path, which Retrofit rejects, so Session.revoke() threw too. Put the @path first. The per-API tests mock these interfaces, so Retrofit never parsed them. ServiceInterfaceValidationTest builds every service ClerkApi creates with validateEagerly(true). DeviceAttestationApi is excluded: its getChallenge() returns void and nothing has called it since #571. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: clerk/clerk-android/.coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. 📝 WalkthroughWalkthroughThe session revocation declaration now lists the target session ID before the optional requesting-session ID, which defaults to the active Clerk session. Password deletion now specifies its API route. Tests cover the revocation request and Retrofit service validation. ChangesAPI Declarations
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The changes correct password deletion and session revocation requests without an identified contract regression. Mergeable subject to normal build and test checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
With the parameter order fixed, Session.revoke() reached the server but got 401 authentication_invalid: revokeSession defaulted _clerk_session_id to null and Session.revoke() never passes it. Default it to the active session, like the other /me endpoints in UserApi. SessionRevokeTest drives Session.revoke() through a real Retrofit SessionApi and asserts the request URL carries the active session id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Verified on an Android emulatorSetup. Workbench app on a clean Pixel (API 36) emulator, test instance Without this PR: tapping "Sign out of this device" crashes the app: pr997-crash-without.mp4With this PR at adc0827: there's no crash. pr997-signout-works.mp4At the earlier head, e685a0d, the crash was gone but the request carried no Not covered here. Right after a successful sign-out, the device list still shows the revoked session until Security reopens. |
swolfand
left a comment
There was a problem hiding this comment.
Both fixes are correct, and the Retrofit-backed tests fail without them. LGTM.
What & why
User.deletePassword()threwIllegalArgumentException("Missing either @POST URL or @Url parameter.")instead of returning aClerkResult.UserApi.deletePasswordhad a bare@POST, and nothing usedApiPaths.User.Password.DELETE. It now posts tome/remove_password. This matches the FAPI spec: a form-encodedcurrent_passwordfield, and a 200 returns the user.Session.revoke()andAuth.revokeSession()threwA @Path parameter must not come after a @Query.becauseSessionApi.revokeSessiondeclared its@Querybefore its@Path. This PR swaps the two parameters. The only caller passes named arguments, so no call sites change.Session.revoke()reached the server but got 401authentication_invalid, becauserevokeSessiondefaulted_clerk_session_idto null andSession.revoke()never passes it. It now defaults to the active session, like the other/meendpoints inUserApi.SessionRevokeTestdrivesSession.revoke()through a real RetrofitSessionApiand checks that the request URL carries the active session id. A teammate checked this on an emulator: revoking from UserProfile > Security > Active devices crashes on main, returns 401 with only the reorder, and returns 200 with this fix.ServiceInterfaceValidationTestbuilds every service thatClerkApicreates withvalidateEagerly(true). An invalid method now fails in CI instead of on a user's first call. Before the fix, the test failed on both methods above.What to focus on
DeviceAttestationApibecause itsgetChallenge()returns void, which Retrofit rejects. Nothing has called that API since refactor(api): remove unused Android device attestation startup flow and middleware #571. Deleting it, along withDeviceAttestationHelperand the Play Integrity dependency, would conflict with feat(protect): integrate mobile challenges #910 and test: audit the unit test suite for tests that don't test anything #985. That deletion is left for a follow-up PR after those two land.ClerkApi, not by scanning thenetwork/api/package, because unit tests load the main classes from a jar. Services added toClerkApilater, such as the Protect APIs in feat(protect): integrate mobile challenges #910, get validated automatically.🤖 Generated with Claude Code
Summary by CodeRabbit