etherpad-lite icon indicating copy to clipboard operation
etherpad-lite copied to clipboard

Session transfer UI treats non-2xx responses as success

Open jingkang0822 opened this issue 3 months ago • 3 comments

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:

Steps to reproduce

Create flow:

  1. Visit the transfer UI without an author cookie, so POST /tokenTransfer returns 400 { "error": "No author cookie to transfer" }.
  2. 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:

  1. Enter a syntactically valid but missing/expired transfer UUID, causing a 404 or 410 JSON response.
  2. 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.

jingkang0822 avatar Aug 28 '26 08:08 jingkang0822

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.

toashu123 avatar Sep 21 '26 12:09 toashu123

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:

  1. Opened http://localhost:9001/ in a fresh Incognito window without first opening a pad.
  2. Opened Settings → Transfer session.
  3. Clicked “Create transfer code.”
  4. The UI displayed a success checkmark and revealed “Copy the transfer code.”
  5. 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.

Image Image Image

jaydeep83721-dev avatar Sep 24 '26 16:09 jaydeep83721-dev

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.

toashu123 avatar Sep 29 '26 06:09 toashu123