Skip to content

fix(auth): decode pushbox Buffer data and add Firefox device tests - #21362

Closed
fxa-agent[bot] wants to merge 1 commit into
mainfrom
agent-067e24
Closed

fxa-agent[bot] wants to merge 1 commit into
mainfrom
agent-067e24

Conversation

@fxa-agent

@fxa-agent fxa-agent Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Because

  • Send Tab is broken on the receiving device. GET /v1/account/device/commands returns a 500 (errno 999). MySQL returns the pushbox data blob as a Buffer, and Buffer.from(buffer, 'base64url') copies a Buffer without decoding it. The bug came in with 1956b6d.
  • No functional test runs Firefox's own FxA device code, so no test caught it.

This pull request

  • Fixes decodeFromStorage in lib/pushbox/index.ts so that it decodes Buffer data and string data.
  • Adds a unit test with Buffer data to lib/pushbox/index.spec.ts, and a store and retrieve round trip through MySQL to pushbox_db.in.spec.ts. Both fail without the fix.
  • Adds firefox-device-helpers.ts and syncV3/firefoxDevices.spec.ts. They sign two real Firefox profiles in to one account and check:
    • both profiles register as Send Tab devices and show in Connected services
    • Send Tab from A opens the tab on B (the end-to-end check for the fix)
    • disconnect B from Settings on A signs B out
    • a password change on A keeps A signed in and signs B out
  • Exports pollUntil from pairing-helpers.ts.

Issue that this pull request solves

Closes:

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • One reviewer call: the new spec runs only on the local target, because it disconnects devices and changes passwords. Is that right for the smoke runs?
  • Risky part: CI has not run the new spec yet. Locally, auth needed JWT_ACCESS_TOKENS_ENABLED_CLIENT_IDS set, because the sandbox has no CMS or Stripe and so no CapabilityManager. I expect CI to have both.

Other information (Optional)

  • I ran /fxa-verify --run --plan: unit 12/12, integration 7/7, lint pass, and the 4 functional tests pass. Without the fix, the Send Tab test fails with errno 999.
  • The tests use Playwright's bundled Firefox, not Nightly.
  • The helpers sign in through the Firefox connect URI, because the /pair flow gives Firefox no Sync keys.
  • Not in this PR: bookmarks and synced tabs tests. They need syncstorage-rs in the test stack.

## Because

- Send Tab is broken on the receiving device. `GET /v1/account/device/commands` returns a 500 (errno 999). MySQL returns the pushbox `data` blob as a Buffer, and `Buffer.from(buffer, 'base64url')` copies a Buffer without decoding it. The bug came in with 1956b6d.
- No functional test runs Firefox's own FxA device code, so no test caught it.

## This pull request

- Fixes `decodeFromStorage` in `lib/pushbox/index.ts` so that it decodes Buffer data and string data.
- Adds a unit test with Buffer data to `lib/pushbox/index.spec.ts`, and a store and retrieve round trip through MySQL to `pushbox_db.in.spec.ts`. Both fail without the fix.
- Adds `firefox-device-helpers.ts` and `syncV3/firefoxDevices.spec.ts`. They sign two real Firefox profiles in to one account and check:
  - both profiles register as Send Tab devices and show in Connected services
  - Send Tab from A opens the tab on B (the end-to-end check for the fix)
  - disconnect B from Settings on A signs B out
  - a password change on A keeps A signed in and signs B out
- Exports `pollUntil` from `pairing-helpers.ts`.

## Issue that this pull request solves

Closes:
@fxa-agent fxa-agent Bot added the auto label Oct 1, 2026
@vbudhram
vbudhram marked this pull request as ready for review October 1, 2026 00:50
@vbudhram
vbudhram requested a review from a team as a code owner October 1, 2026 00:50
Copilot AI lite review requested due to automatic review settings October 1, 2026 00:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Resolve the functional-test TypeScript error and correct the Pushbox Buffer type contract.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes Pushbox Buffer decoding and adds Firefox device coverage for Send Tab and session invalidation.

Changes:

  • Decode string and Buffer payloads correctly.
  • Add unit and MySQL round-trip tests.
  • Add Firefox device functional tests and polling helpers.
File Summary
packages/​fxa-auth-server/​test/​remote/​pushbox_db.in.spec.ts Adds database round-trip coverage.
packages/​fxa-auth-server/​lib/​pushbox/​index.ts Decodes Buffer payloads; update types to include Buffer and remove the cast.
packages/​fxa-auth-server/​lib/​pushbox/​index.spec.ts Tests Buffer decoding.
packages/​functional-tests/​tests/​syncV3/​firefoxDevices.spec.ts Adds Firefox device scenarios; fixes the boolean versus true return-type error.
packages/​functional-tests/​lib/​pairing-helpers.ts Exports pollUntil.
packages/​functional-tests/​lib/​firefox-device-helpers.ts Adds Firefox device automation helpers.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +53 to +56
return pollUntil(
async () =>
(await getDeviceList(client)).every((d) => d.id !== deviceId) ||
undefined,
);
}

test.describe('severity-2', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to move this from tests/syncV3 folder, it isnt related to syncV3, perhaps we can have a generic sync folder?

@vbudhram vbudhram self-assigned this Oct 1, 2026
@vbudhram

vbudhram commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Closing for now

@vbudhram vbudhram closed this Oct 1, 2026
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.

2 participants