Session transfer UI treats non-2xx responses as success
Description
The session-transfer UI treats non-2xx responses as successful because neither request checks response.ok or validates the expected response shape.
This is present on develop at f2cf95e06cd613fd0a06bbcb755e044c1dbfe306:
- The create flow shows success before parsing the response and later copies
responseData.id - The redeem flow reloads after parsing any JSON response
- The server intentionally returns JSON errors with 400, 404, and 410 statuses
Steps to reproduce
Create flow:
- Visit the transfer UI without an author cookie, so
POST /tokenTransferreturns400 { "error": "No author cookie to transfer" }. - Click “Transfer session now”.
The button changes to a checkmark and the copy section is shown. Clicking copy writes undefined because the error body has no id.
Redeem flow:
- Enter a syntactically valid but missing/expired transfer UUID, causing a 404 or 410 JSON response.
- Click the transfer button.
The page reloads as if redemption succeeded.
Expected behavior
The UI should only show success or reload after a 2xx response with the expected body. For an error, it should display the server message (or a localized fallback), restore usable controls, and preserve the page state.
Possible direction
Check response.ok before the success transition, validate id/ok, and handle fetch/JSON failures in both paths.
No plugins are required. I found this while benchmarking an automated code-review workflow and manually verified the current source and duplicate search before reporting it.
Hi, I'd like to work on this issue.
I'll update the session-transfer UI to handle non-2xx responses correctly, preserve the current page state on errors, and add regression coverage where appropriate.
I reproduced this on the current develop branch.
Environment:
- Etherpad: 3.3.6
- Commit:
eead0e7dd314da8be0657887e3388e8f90dd6626 - macOS: 26.6.2 (Build 25G83)
- Node.js: 26.8.1
- pnpm: 12.4.2
- Browser: Chrome, Incognito mode
Steps:
- Opened
http://localhost:9001/in a fresh Incognito window without first opening a pad. - Opened Settings → Transfer session.
- Clicked “Create transfer code.”
- The UI displayed a success checkmark and revealed “Copy the transfer code.”
- Clicking the copy button copied
undefined.
Expected:
The UI should display the server error and remain usable without showing a successful transfer state.
Actual:
The UI displays success even though no valid transfer code was created, and the copy action writes undefined to the clipboard.
I have attached screenshots showing the false success state and the copied undefined value.
Hi @jaydeep83721-dev , I have open the pull request, please validate it and if possible then merge. I am open for any discussion regarding the changes and if any further modifications needed then inform me.