Skip to content

Surface an actionable error when the Connect server URL redirects #4316

Description

@christierney

Context

#4262 was closed as wontfix: Publisher will not follow HTTP redirects with credentials across origin changes, and #4315 fixes the common case (http→https upgrade) by resolving redirects once at credential-creation time and storing the post-redirect URL.

That leaves stale credentials — created before #4315 lands, or pointing at servers that later add an [HTTPRedirect] config or migrate to a new host. When such a credential is used to publish, the failure messages are misleading:

  • Host change (e.g. server migration): axios's follow-redirects transport strips Authorization when the redirect crosses to a different, non-subdomain host, so the first publish request (GET /__api__/v1/user) follows the redirect unauthenticated and gets a 401. The user sees "authorization failed," which is misleading — their API key is fine; their credential URL is stale.
  • http→https upgrade on the same host: follow-redirects preserves Authorization on an https upgrade, so every preflight request silently succeeds, and the publish fails at the bundle upload (the one request with maxRedirects: 0) with Unexpected response from the server (302: ...) — no hint that a redirect occurred or where it pointed.

Proposal

Detect 3xx responses and surface an actionable error, e.g.:

Your server URL redirects to https://…. Update your credential's server URL and try again.

At minimum this should cover:

  • testAuthentication (catches host-change redirects before auth is stripped mid-flight — a 3xx with maxRedirects: 0 on this probe, or inspection of the final URL, would reveal the redirect)
  • uploadBundle in @posit-dev/connect-api, where a 3xx currently falls into the generic "Unexpected response" branch of classifyDeploymentError

No redirect should be followed with credentials attached; the goal is purely a better error message pointing the user at the fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    communityIssues with external community involvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions