Skip to content

fix(desktop): fetch join policies through native networking#2862

Open
johnmatthewtennant wants to merge 5 commits into
block:mainfrom
johnmatthewtennant:jtennant/fix-add-community-policy-fetch
Open

fix(desktop): fetch join policies through native networking#2862
johnmatthewtennant wants to merge 5 commits into
block:mainfrom
johnmatthewtennant:jtennant/fix-add-community-policy-fetch

Conversation

@johnmatthewtennant

@johnmatthewtennant johnmatthewtennant commented Jul 25, 2026

Copy link
Copy Markdown

Summary

Adding an existing community by relay URL could fail with Community rejected: Load failed even when its WebSocket endpoint was reachable. The Add Community flow fetched /api/join-policy from the WebView, so a relay without a matching CORS allowance blocked the policy request before the app could join it.

This bug fix:

  • Fetches join policies through Tauri's native networking layer for Add Community and first-community direct URL joins.
  • Validates relay schemes, rejects URLs containing credentials, and refuses redirects.
  • Bounds native policy responses before JSON parsing, including declared and chunked bodies.
  • Preserves existing 404, non-success status, malformed JSON, and absent-policy behavior.
  • Keeps invite-code discovery, policy acceptance, and signed invite claims on the WebView path so those operations migrate together later.
  • Makes every join-policy caller choose its transport explicitly.

Public relays using Buzz's default permissive CORS configuration are not known to be affected.

Related issue

Related to #2872.

Testing

End-to-end red/green requires access to a relay with a restrictive CORS configuration and a Buzz identity authorized to join it.

Red: main

From a clean checkout of main:

just staging

In Buzz Desktop:

  1. Add another community so the restrictive-CORS relay can be removed.
  2. Remove that relay.
  3. Open Add Community and enter the relay's WebSocket URL.
  4. Select Add Community.

Observed result:

Community rejected: Load failed

Green: this PR

From a clean checkout of this branch:

just staging

Repeat the same steps above.

Observed result:

The community rejoins successfully.

Supporting checks:

  • Six native join-policy tests, including oversized declared and chunked responses.
  • Four TypeScript API tests, including the native command contract.
  • E2E build and four focused onboarding/sidebar Playwright tests.
  • Full desktop and Tauri pre-push test suites.

@johnmatthewtennant
johnmatthewtennant marked this pull request as ready for review July 25, 2026 16:55
@johnmatthewtennant
johnmatthewtennant requested a review from a team as a code owner July 25, 2026 16:55
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/fix-add-community-policy-fetch branch from 45113e5 to 238526f Compare July 25, 2026 17:25

@bp2m6v4sp5-dev bp2m6v4sp5-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Submit

@wpfleger96 wpfleger96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 hey @johnmatthewtennant — I like the direction here, native networking is clearly the right escape hatch for a CORS-restricted relay, and the redirect refusal + credential rejection are nice hardening on top. Two things I'd want changed before this goes in, plus a few smaller notes inline.

Blocking, both left as inline comments:

  1. the native command buffers the whole response body from an arbitrary user-entered relay (response.json())
  2. transport defaults to "webview" — the broken path is the default a new caller gets

Non-blocking notes:

desktop/src/shared/api/invites.test.mjs still only exercises the webview branch (every getJoinPolicy call in it omits the transport arg). Worth one native-transport case that pins the command name fetch_join_policy, the relayUrl arg shape, and the mapping — the two branches aren't symmetric (webview unwraps raw.policy, native returns the already-unwrapped policy), and right now nothing on the TS side locks that down.

The reported bug still reproduces for invite-URL joins against the same relay, since getJoinPolicy on the invite path, acceptJoinPolicy, and claimInvite all stay on webview fetch. I get why (the description says as much) — could you file a follow-up issue and link it here so the remaining half doesn't get lost?

Nothing here looks wrong to me on the parts I didn't comment on: 404/non-success/malformed-JSON semantics match the old flow, and I ran the URL builder against .. traversal, %2F-encoded segments, IPv6 hosts, uppercase schemes, and bare ws:///foo — all either rejected or normalized sanely.

Comment thread desktop/src-tauri/src/commands/join_policy.rs Outdated
Comment thread desktop/src/shared/api/invites.ts Outdated
Comment thread desktop/tests/e2e/sidebar.spec.ts
Comment thread desktop/src/features/communities/ui/CommunityEditForm.tsx
Comment thread desktop/src/features/onboarding/ui/InviteRedeemForm.tsx
…unity-policy-fetch

* origin/main:
  Fix formatting in README.md diagram (block#2284)
  fix(desktop): make Linux AppImage GStreamer work on non-Debian distros (block#2176)
  refactor(desktop): remove Agent directory section from Agents page (block#2290)
  fix(desktop): enable arboard Wayland backend so Linux copies reach the Wayland clipboard (block#2904)
  fix(desktop): supervise and re-arm relay-mesh runtime (block#2823)
  fix(agents): run live Databricks discovery instead of the fallback list (block#2890)
  fix(desktop): retire prepend mode on every reader wheel (block#2913)
  fix(desktop): consolidate prepend scroll correction (block#2855)
  docs(buzz-acp): correct agent key generation instructions (block#2875)
  fix(desktop): track concurrent agent turns up to the harness maximum (block#2882)
  docs(contributing): trim to goose-scale minimal intake surface (block#2780)
  fix(relay): preserve reconnect backoff (block#2759)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants