Skip to content

fix(cli): collab sync diagnostics β€” stable cherry-pick (SD-3233)#3408

Merged
caio-pizzol merged 2 commits into
stablefrom
tadeu/sd-3233-stable-cherry-pick
May 20, 2026
Merged

fix(cli): collab sync diagnostics β€” stable cherry-pick (SD-3233)#3408
caio-pizzol merged 2 commits into
stablefrom
tadeu/sd-3233-stable-cherry-pick

Conversation

@tupizz

@tupizz tupizz commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Cherry-picks the SD-3233 collaboration-diagnostics fix from PR #3404 (caio/collab-timeout-diagnostics β†’ main) onto stable so we can cut a patch CLI release (e.g. 1.8.1 β†’ 1.8.2) without dragging in everything else on main.

Authorship preserved on both commits (Caio Pizzol).

Commits

Commit Subject
966b3e988 fix(cli): include provider diagnostics in collaboration sync timeouts
bfe0ff75f fix(cli): guard URI decode in collaboration diagnostics sanitization

Both cherry-picked clean against origin/stable β€” no conflicts.

What changes for the customer

Before: COLLABORATION_SYNC_TIMEOUT errors came back with details: { timeoutMs: 10000 } only. Customer had no way to tell whether the broker rejected auth, the TLS handshake failed, the hostname didn't resolve, or the server was just silent.

After: details now includes providerType, sanitized url (with ?token=[REDACTED]), documentId, tokenEnvConfigured / authTokenResolved split, paramsKeys, eventCounts, providerState, and per-event-type last* snapshots (lastConnectionClose, lastConnectionError, lastAuthenticationFailed, lastClose, lastDisconnect, lastStatus).

Same error code (COLLABORATION_SYNC_TIMEOUT) β€” fully backward-compatible for any SDK consumer matching on the code.

Verification on this branch

Suite

  • pnpm --filter @superdoc-dev/cli test -- --run collaboration β€” 92 pass, 0 fail across 4 files.
  • pnpm --filter @superdoc-dev/cli test (full) β€” 1251 pass, 0 fail, 8262 expect() across 51 files.
  • Compiled SEA binary builds clean with bun build --compile.

End-to-end against the real triage servers (*.collab.superdoc.dev)

Ran the customer-shape --collaboration-json invocation on the compiled SEA binary built off this branch:

# Endpoint Token Result Key field in envelope
A1 y-websocket valid ok: true n/a
A2 y-websocket none timeout lastConnectionClose: { code: 1002, reason: "Expected 101 status code" }, tokenEnvConfigured: false
A3 y-websocket wrong timeout same as A2 + URL shows ?token=[REDACTED]
B1 hocuspocus valid ok: true n/a
B2 hocuspocus none timeout tokenEnvConfigured: false, stuck connecting
B3 hocuspocus wrong timeout lastAuthenticationFailed: { reason: "permission-denied" }
C1 unreachable host n/a timeout lastConnectionClose: { code: 1006, reason: "Failed to connect" }

Same envelope shape as on main (PR #3404). Stable-line behaviour is identical.

Release plan

Once merged, cut a patch from stable (e.g. 1.8.2). The customer (chynes / Lighthouse) can drop in the new binary and rerun their failing invocation; their error envelope will now include lastConnectionClose / lastAuthenticationFailed / etc. and they can self-diagnose whether the failure is on our side or their broker.

Related

Before, COLLABORATION_SYNC_TIMEOUT details only contained
{ timeoutMs }. DNS failures, refused TCP, failed WS upgrades, and
auth rejections all collapsed to the same useless payload. The
timeout now captures last status/connection-error/connection-close/
authenticationFailed plus event counts, sanitized URL, documentId,
tokenEnv state, and paramsKeys.

Sensitive query params are redacted in URL and event payload
strings. y-websocket's [event, provider] emit pattern is reduced
to the first arg so the provider self-ref graph does not bloat
the envelope or risk leaking document content.

Mock constructors in runtime.test.ts updated: the previous pattern
returned undefined instances under bun's mock wrapping, which was
harmless when the runtime did not touch the provider synchronously.
The new attachProviderDiagnostics binding does.
decodeURIComponent throws URIError on malformed percent-encoding
(e.g. a raw `%` in a query key). The diagnostics sanitizer runs
inside the sync-timeout callback, so an uncaught throw would
suppress the COLLABORATION_SYNC_TIMEOUT envelope entirely - the
exact failure mode the rest of the module defends against.

Falls back to the raw key on URIError so the sensitivity check
still runs. Decoding stays in place so encoded variants like
`%74oken` continue to redact correctly.
@tupizz
tupizz requested a review from a team as a code owner May 20, 2026 17:17
@linear-code

linear-code Bot commented May 20, 2026

Copy link
Copy Markdown

SD-3233

@caio-pizzol caio-pizzol 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.

lgtm

@caio-pizzol
caio-pizzol enabled auto-merge May 20, 2026 17:19
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.

πŸ“’ Thoughts on this report? Let us know!

@caio-pizzol
caio-pizzol disabled auto-merge May 20, 2026 17:47
@caio-pizzol
caio-pizzol merged commit 9acc772 into stable May 20, 2026
18 checks passed
@caio-pizzol
caio-pizzol deleted the tadeu/sd-3233-stable-cherry-pick branch May 20, 2026 17:47
@superdoc-bot

superdoc-bot Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in superdoc-sdk v1.10.1

@superdoc-bot

superdoc-bot Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in @superdoc-dev/mcp v0.6.1

The release is available on GitHub release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants