{"record":{"id":"a079fe9aef4a547b","repo":"can1357/oh-my-pi","slug":"the-upload-response-url-must-use-http-or-https","errorCode":null,"errorMessage":"the upload response URL must use HTTP or HTTPS","messagePattern":"the upload response URL must use HTTP or HTTPS","errorType":"exception","errorClass":"LegacyDestinationError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/blob-broker/uploaders-legacy.ts","lineNumber":103,"sourceCode":"}\n\nfunction sendSpaceEndpoint(config: DestinationRuntimeConfig): URL {\n\tconst endpoint = configuredEndpoint(\"sendspace\", config);\n\tif (endpoint.hostname.toLowerCase() === SENDSPACE_DEFAULT_HOST) {\n\t\tthrow new DestinationUnavailableError(\"sendspace\", \"the deprecated public discovery endpoint cannot be used\");\n\t}\n\treturn endpoint;\n}\n\nfunction httpUrl(destination: BlobDestinationId, raw: string, base?: URL): string {\n\tlet url: URL;\n\ttry {\n\t\turl = base ? new URL(raw, base) : new URL(raw);\n\t} catch (error) {\n\t\tthrow new LegacyDestinationError(destination, \"the upload response did not contain a valid direct URL\", error);\n\t}\n\tif (url.protocol !== \"https:\" && url.protocol !== \"http:\") {\n\t\tthrow new LegacyDestinationError(destination, \"the upload response URL must use HTTP or HTTPS\");\n\t}\n\treturn url.href;\n}\n\nfunction objectValue(value: unknown): Readonly<Record<string, unknown>> {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) return {};\n\treturn value as Readonly<Record<string, unknown>>;\n}\n\nfunction firstString(record: Readonly<Record<string, unknown>>, keys: readonly string[]): string | undefined {\n\tfor (const key of keys) {\n\t\tconst value = record[key];\n\t\tif (typeof value === \"string\" && value.trim()) return value.trim();\n\t}\n\treturn undefined;\n}\n\nasync function jsonObject(","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/blob-broker/uploaders-legacy.ts#L85-L121","documentation":"This LegacyDestinationError is thrown by httpUrl() when the URL from the upload response parses successfully but its protocol is not `https:` or `http:`. Like the configured-endpoint protocol check, it guarantees the returned direct-download URL is fetchable over HTTP(S).","triggerScenarios":"The upload endpoint's response contains a URL with an unusual scheme — e.g. 'ftp://host/f.png', a 'data:image/png;base64,...' URI, or a javascript:/file: URL in a field the library treats as a direct link; thrown from directJsonUrl/url/upload/discoverSendSpaceNode.","commonSituations":"Replacement endpoints that return data-URIs for inline images; misconfigured servers emitting internal scheme links; hand-written response shims returning non-HTTP URLs.","solutions":["Configure the endpoint (or its response) to return absolute `https://` URLs for the uploaded file","If the endpoint returns data-URIs, add a wrapper that stores the bytes and returns an HTTP URL instead","Inspect the response body to confirm which scheme the URL field carries and adjust the server"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isHttpUrlString(value: unknown): value is string {\n  if (typeof value !== \"string\") return false;\n  try { return /^https?:$/.test(new URL(value).protocol); } catch { return false; }\n}","tryCatchPattern":"try {\n  const result = await uploader.upload(request);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"must use HTTP or HTTPS\")) {\n    // server returned a non-HTTP scheme (data:, ftp:, ...) in its response URL\n  } else throw err;\n}","preventionTips":["Configure endpoints to return http(s) URLs, not data-URIs or other schemes","Proxy data-URI responses through a store-and-serve layer","Verify response URL schemes during endpoint integration testing","Reject non-HTTP URL fields server-side before returning them to clients"],"tags":["network","upload","url","protocol","response-parsing"],"backgroundTag":"malformed-upload-response","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}