Skip to content

fix(api): route requests to the correct regional Plaud host - #14

Open
fcroiseaux wants to merge 1 commit into
leonardsellem:mainfrom
fcroiseaux:fix/regional-host-routing
Open

fix(api): route requests to the correct regional Plaud host#14
fcroiseaux wants to merge 1 commit into
leonardsellem:mainfrom
fcroiseaux:fix/regional-host-routing

Conversation

@fcroiseaux

Copy link
Copy Markdown

Problem

Syncs stopped working with a Plaud sync failed: unexpected API response format notice. Plaud retired the global api.plaud.ai host in favor of region-specific hosts (api-euc1, api-use1, api-apse1), and each account's region is baked into its JWT. Calling the wrong host now returns an envelope with msg: "user region mismatch", which the client mapped to a fatal invalid_response — breaking every sync for anyone whose account is not on the (now dead) global host.

Root cause was confirmed from the live API response, not just docs: the failing call is listFiles()GET /file/simple/web (the only unguarded call in runPlaudSync; per-file getFileDetail failures are caught and counted, so they can't produce the top-level "sync failed" notice). The captured envelope was { status: <non-zero>, msg: "user region mismatch" }.

Fix

  • Regional host auto-detection. The API client probes the known regional hosts, sticks to the one that accepts the token, and reuses it for later calls. A new onHostResolved callback lets the plugin persist the resolved host so subsequent sessions skip re-probing (self-healing, and no manual region configuration required).
  • Default domain moves from the dead api.plaud.ai to api-euc1.plaud.ai; the settings copy documents that the region is auto-detected (euc1 EU / use1 US / apse1 APAC).
  • Listing query parameters (skip/limit/is_trash/sort_by/is_desc) are now sent to match the current /file/simple/web contract used by other Plaud clients.

Tests

  • Added coverage for regional failover, resolved-host reuse (no re-probing), onHostResolved semantics, and the all-hosts-rejected error path.
  • Updated the default-domain assertion.
  • Full suite passes (59/59), npm run build typecheck is green.

🤖 Generated with Claude Code

Plaud retired the global `api.plaud.ai` host in favor of region-specific
hosts (`api-euc1`/`api-use1`/`api-apse1`), with each account's region baked
into its JWT. Calling the wrong host now returns an envelope with
`msg: "user region mismatch"`, which the client surfaced as a fatal
`invalid_response` and broke every sync.

The API client now probes the known regional hosts, sticks to the one that
accepts the token, and persists it via `onHostResolved` so later sessions
skip re-probing. The default domain moves to the EU host, and the settings
copy documents that the region is auto-detected. Also send the listing
query parameters (`skip`/`limit`/`is_trash`/`sort_by`/`is_desc`) that the
current `/file/simple/web` contract expects.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant