can1357/oh-my-pi · error · LegacyDestinationError

resultBaseUrl is not a valid URL

Error message

resultBaseUrl is not a valid URL

What it means

Thrown at uploader construction time (createLambdaUploader, reached via createLegacyUploader) when the optional 'resultBaseUrl' option in the destination config cannot be parsed by the URL constructor. This is a configuration error, not a network problem — no request is made. The original parse error is attached as the cause.

Source

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

					remoteId ? { remoteId } : undefined,
				);
			} catch (error) {
				throw failure(destination, error);
			}
		},
	};
}

function createLambdaUploader(config: DestinationRuntimeConfig, endpoint: URL): BlobUploader {
	const destination = "lambda" as const;
	const apiKey = requireCredential(config, "apiKey");
	const resultBase = optionString(config, "resultBaseUrl");
	let resultBaseUrl: URL = endpoint;
	if (resultBase) {
		try {
			resultBaseUrl = new URL(resultBase);
		} catch (error) {
			throw new LegacyDestinationError(destination, "resultBaseUrl is not a valid URL", error);
		}
	}
	return {
		destination,
		async upload(request) {
			try {
				const response = await fetchFor(config)(endpoint, {
					method: "PUT",
					body: multipartFile(request, "file", { api_key: apiKey }),
				});
				await expectOk(response, destination);
				const data = await jsonObject(destination, response);
				const errors = data.errors;
				if (Array.isArray(errors) && errors.length > 0) {
					throw new LegacyDestinationError(destination, "the replacement endpoint rejected the upload");
				}
				const raw = firstString(data, ["direct_url", "directUrl", "url"]);
				if (!raw)

View on GitHub (pinned to 9690622007)

Solutions

  1. Fix the resultBaseUrl value to include the scheme, e.g. https://results.example.com/
  2. Trim whitespace and remove template placeholders from the config value
  3. Validate the URL in your own config loader before passing it to createLegacyUploader

Example fix

// before
{ endpoint: "https://lbda.net/api", resultBaseUrl: "results.myhost.com" }
// after
{ endpoint: "https://lbda.net/api", resultBaseUrl: "https://results.myhost.com" }
Defensive patterns

Strategy: validation

Validate before calling

function validateResultBaseUrl(raw: unknown): URL {
	if (typeof raw !== "string") throw new Error("resultBaseUrl must be a string");
	const url = new URL(raw.trim());
	if (url.protocol !== "https:" && url.protocol !== "http:") throw new Error("resultBaseUrl must be http(s)");
	return url;
}
validateResultBaseUrl(config.resultBaseUrl); // before createLegacyUploader

Try / catch

try {
	const uploader = createLegacyUploader(destination, config);
} catch (err) {
	if (err instanceof Error && /resultBaseUrl is not a valid URL/.test(err.message)) {
		throw new Error(`Fix resultBaseUrl in config for ${err.message.split(":")[0]} — include the scheme, e.g. https://`);
	}
	throw err;
}

Prevention

When it happens

Trigger: Calling createLegacyUploader with config option resultBaseUrl set to something like 'myhost.com/results' (missing scheme) or containing stray whitespace/characters, so new URL(resultBase) throws.

Common situations: Typo in config file omitting https://; copy-pasting a relative path as the base URL; environment-specific config templating leaving a placeholder value like '${RESULT_BASE}'.

Related errors


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