Skip to content

provide-hub: fail fast on a non-ws(s) --server URL (bd-q96fhj3q) - #845

Merged
shikokuchuo merged 1 commit into
mainfrom
bugfix/bd-q96fhj3q-dialer-permanent-failure
Oct 15, 2026
Merged

shikokuchuo merged 1 commit into
mainfrom
bugfix/bd-q96fhj3q-dialer-permanent-failure

Conversation

@shikokuchuo

Copy link
Copy Markdown
Member

What this fixes

q2 provide-hub --server https://… used to retry for 30 seconds and then fail with "timed out connecting to hub" or "hub connection failed (auth rejected?)". Both messages named the wrong cause. The real problem: the scheme was https, and only ws:// and wss:// work. Retrying could never help, because the URL is fixed when the dialer starts.

The change

  • build_auth_request now checks the scheme up front and returns a new ProviderError::InvalidUrl.
  • The dialer maps that error (and tungstenite's connect-time URL error) to DialError::PermanentFailure, so samod stops retrying at once. Token fetches and network errors stay transient: a fresh token is fetched per attempt, so an auth rejection can still clear on retry.
  • join surfaces the real cause. The error now reads: hub connection failed: invalid websocket url: unsupported scheme 'https' (the server URL must use ws:// or wss://).

Verification

  • Four new dialer tests and one join test, watched failing first. One surprise along the way: tungstenite 0.27 accepts https:// when it builds the request and only rejects the scheme at connect, so the guard covers both layers.
  • quarto-hub-provider: 45/45 pass.
  • End to end: q2 provide-hub someDocId --file index.qmd --server https://example.test/ws --token tok now fails in about 2 seconds with the message above. Before, it took 30 seconds and blamed a timeout.
  • Full workspace suite: the only failures were ten typst book tests. Their typst package download from packages.typst.org was throttled under full test parallelism; they pass on their own and at -j 2. This change does not touch typst.

Closes bd-q96fhj3q.

…-q96fhj3q)

samod 0.14 split DialError into TransientFailure (retried with backoff)
and PermanentFailure (stops the dialer, surfaced via established()); the
upgrade mapped every BearerDialer failure to transient to preserve 0.13
semantics. A non-ws(s) --server URL (the classic https:// paste) is
fixed at construction, so retrying could never succeed: every attempt
failed tungstenite's scheme check and the user got 30 s of futile dials
ending in 'timed out connecting to hub' / 'auth rejected?'.

- build_auth_request validates the scheme up front and returns the new
  ProviderError::InvalidUrl (tungstenite only checks the scheme at
  connect); Handshake keeps the bearer-header case, which stays
  transient because a fresh token is fetched per attempt
- connect maps InvalidUrl, and tungstenite's connect-time Error::Url,
  to DialError::PermanentFailure; token-fetch and network errors stay
  transient
- join surfaces the permanent cause instead of guessing auth:
  'hub connection failed: invalid websocket url: unsupported scheme
  \'https\' (the server URL must use ws:// or wss://)'

Tests watched fail first, including one surprise the strand did not
predict: tungstenite 0.27's into_client_request accepts https://, so
the failure surfaced at connect_async, not at request build — the
scheme guard now lives in build_auth_request. New coverage: scheme
guard unit test, connect-level permanent/transient classification with
guards that the bearer-header and token-fetch cases stay transient, and
a join-level test asserting fast failure naming the URL.
quarto-hub-provider 45/45 pass; full workspace suite deferred per user
request.
@posit-snyk-bot

posit-snyk-bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@shikokuchuo
shikokuchuo merged commit 2d34c48 into main Oct 15, 2026
11 checks passed
@shikokuchuo
shikokuchuo deleted the bugfix/bd-q96fhj3q-dialer-permanent-failure branch October 15, 2026 12:48
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.

2 participants