frontend: handle session transfer request failures - #8180
Conversation
Only treat a session transfer as successful after receiving a successful response with the expected payload, and restore usable controls on errors. Fixes ether#8172
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoHandle session transfer request failures in the welcome UI
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1. id accepts malformed values
|
| if (!responseData || typeof responseData !== 'object' || | ||
| !('id' in responseData) || typeof transferData.id !== 'string' || | ||
| transferData.id.trim() === '') { |
There was a problem hiding this comment.
1. id accepts malformed values 📎 Requirement gap ≡ Correctness
The create flow treats every non-empty string as a valid transfer ID, so a malformed 2xx payload
such as {id: "x"} exposes a copy-success state containing an unusable code. Created IDs are UUIDs
and the redeem flow requires 36 characters, but this validation does not enforce that format.
Agent Prompt
## Issue description
The create-session response accepts any non-empty string as a transfer ID, allowing malformed IDs to trigger the success and copy UI.
## Issue Context
The server creates IDs with `crypto.randomUUID()`, and the receive flow expects a 36-character transfer code. Validate the returned ID against the actual UUID format before exposing it, and add regression coverage for non-empty malformed IDs.
## Fix Focus Areas
- src/static/js/welcome.ts[86-89]
- src/tests/frontend-new/specs/welcome.spec.ts[109-126]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| } | ||
| window.location.reload() | ||
| } catch (err) { | ||
| transferSessionButton.disabled = !isValidTransferCode(code); |
There was a problem hiding this comment.
2. Stale code enables submit 🐞 Bug ≡ Correctness
When redemption fails, redeemTransferCode() restores the button from the captured submitted code, not the code currently in the editable input. If the user changes the input to an invalid value while the request is pending, the catch block overrides the input listener and enables the button, allowing an invalid redemption request.
Agent Prompt
## Issue description
A failed redeem request re-enables the transfer button according to the originally submitted code, even when the user has since edited the input to an invalid value.
## Issue Context
The input remains editable while the fetch is pending. Its input listener correctly updates the disabled state from the current value, but the request catch block can later overwrite that state using stale data.
## Fix Focus Areas
- src/static/js/welcome.ts[119-145]
- src/static/js/welcome.ts[182-201]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Summary
{ok: true}.spec.tsconvention and add regression coverage for the failure pathsValidation
corepack pnpm --filter ep_etherpad-lite run ts-checkcorepack pnpm run build:etherpadcorepack pnpm exec playwright test tests/frontend-new/specs/welcome.spec.ts --project=chromium --project=firefox --reporter=list— 28 passedcorepack pnpm exec cross-env NODE_ENV=production npx mocha --import=tsx --timeout 120000 tests/backend/specs/tokenTransfer.ts— 6 passingcorepack pnpm --filter ep_etherpad-lite run test:vitest— 49 files / 724 tests passedgit diff --checkThe repository's current lint command fails on both this candidate and its pristine base before source analysis because ESLint 10 cannot find a flat
eslint.config.*; the candidate does not modify lint configuration.Fixes #8172