can1357/oh-my-pi · error · LegacyDestinationError

the configured endpoint must use HTTP or HTTPS

Error message

the configured endpoint must use HTTP or HTTPS

What it means

This LegacyDestinationError is thrown when the configured endpoint parses as a valid URL but its protocol is neither `https:` nor `http:`. The uploader only speaks HTTP(S), so schemes like `ftp:`, `file:`, `ws:`, or `data:` are rejected before any request is made.

Source

Thrown at packages/coding-agent/src/blob-broker/uploaders-legacy.ts:73

function failure(destination: BlobDestinationId, error: unknown): Error {
	if (error instanceof DestinationUnavailableError || error instanceof LegacyDestinationError) return error;
	const message = error instanceof Error ? error.message : String(error);
	return new LegacyDestinationError(destination, message, error);
}

function configuredEndpoint(destination: BlobDestinationId, config: DestinationRuntimeConfig): URL {
	const raw = optionString(config, "endpoint")?.trim();
	if (!raw) {
		throw new DestinationUnavailableError(destination, "a user-supplied replacement endpoint is required");
	}
	let endpoint: URL;
	try {
		endpoint = new URL(raw);
	} catch (error) {
		throw new LegacyDestinationError(destination, "the configured endpoint is not a valid URL", error);
	}
	if (endpoint.protocol !== "https:" && endpoint.protocol !== "http:") {
		throw new LegacyDestinationError(destination, "the configured endpoint must use HTTP or HTTPS");
	}
	const hostname = endpoint.hostname.toLowerCase();
	const blocked = BLOCKED_CUSTOM_HOSTS[destination];
	if (blocked) {
		for (const domain of blocked) {
			if (hostname === domain || hostname.endsWith(`.${domain}`)) {
				throw new DestinationUnavailableError(destination, "the defunct public endpoint cannot be used");
			}
		}
	}
	return endpoint;
}

function sendSpaceEndpoint(config: DestinationRuntimeConfig): URL {
	const endpoint = configuredEndpoint("sendspace", config);
	if (endpoint.hostname.toLowerCase() === SENDSPACE_DEFAULT_HOST) {
		throw new DestinationUnavailableError("sendspace", "the deprecated public discovery endpoint cannot be used");
	}

View on GitHub (pinned to 9690622007)

Solutions

  1. Change the endpoint scheme to `https://` (preferred) or `http://` for local/internal networks
  2. If the target only speaks another protocol (e.g. FTP), it is not usable as this destination's endpoint; find an HTTP gateway
  3. Verify the full URL string in config includes the intended scheme and no `file://` path was substituted

Example fix

// before
endpoint: ftp://files.example.com/upload
// after
endpoint: https://files.example.com/upload
Defensive patterns

Strategy: validation

Validate before calling

const u = new URL(config.endpoint);
if (u.protocol !== "https:" && u.protocol !== "http:") {
  throw new Error(`endpoint scheme must be http/https, got ${u.protocol}`);
}

Type guard

function isHttpProtocolUrl(u: URL): boolean {
  return u.protocol === "https:" || u.protocol === "http:";
}

Try / catch

try {
  await uploader.upload(request);
} catch (err) {
  if (err instanceof Error && err.message.includes("must use HTTP or HTTPS")) {
    // rewrite endpoint with https:// scheme
  } else throw err;
}

Prevention

When it happens

Trigger: Setting config.endpoint for a legacy destination to a URL with a non-HTTP scheme, e.g. 'ftp://files.example.com/up', 'file:///tmp/upload', or a websocket 'wss://...' URL; the check runs in configuredEndpoint() right after successful URL parsing.

Common situations: Users assume other protocols are supported; accidentally pasting a `file://` local path as an endpoint; using a scheme-relative or custom internal protocol from another tool's config.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/4be90c487515d123. Report an issue: GitHub.