{"record":{"id":"a540431826a34781","repo":"earendil-works/pi","slug":"server-url-must-use-http-or-https","errorCode":null,"errorMessage":"Server URL must use http or https","messagePattern":"Server URL must use http or https","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/extensions/llama/client.ts","lineNumber":144,"sourceCode":"\t};\n}\n\nexport function formatBytes(bytes: number): string {\n\tif (bytes < 1024) return `${bytes} B`;\n\tconst units = [\"KiB\", \"MiB\", \"GiB\", \"TiB\"];\n\tlet value = bytes / 1024;\n\tlet unit = units[0]!;\n\tfor (let index = 1; index < units.length && value >= 1024; index++) {\n\t\tvalue /= 1024;\n\t\tunit = units[index]!;\n\t}\n\treturn `${value >= 10 ? value.toFixed(1) : value.toFixed(2)} ${unit}`;\n}\n\nexport function normalizeLlamaServerUrl(value: string): string {\n\tconst url = new URL(value.trim());\n\tif (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n\t\tthrow new Error(\"Server URL must use http or https\");\n\t}\n\turl.hash = \"\";\n\turl.search = \"\";\n\turl.pathname = url.pathname.replace(/\\/+$/u, \"\").replace(/\\/v1$/u, \"\") || \"/\";\n\treturn url.toString().replace(/\\/$/u, \"\");\n}\n\nexport function llamaInferenceUrl(serverUrl: string): string {\n\treturn `${normalizeLlamaServerUrl(serverUrl)}/v1`;\n}\n\nexport class LlamaClient {\n\treadonly serverUrl: string;\n\tprivate readonly apiKey: string | undefined;\n\n\tconstructor(serverUrl: string, apiKey?: string) {\n\t\tthis.serverUrl = normalizeLlamaServerUrl(serverUrl);\n\t\tthis.apiKey = apiKey;","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/coding-agent/src/extensions/llama/client.ts#L126-L162","documentation":"Error \"Server URL must use http or https\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/coding-agent/src/extensions/llama/client.ts:144 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}