{"record":{"id":"0092e9078c16b81e","repo":"alibaba/nacos","slug":"invalid-endpoint-uri-uri-0092e9","errorCode":null,"errorMessage":"Invalid Endpoint URI: ${uri}","messagePattern":"Invalid Endpoint URI: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"console-ui-next/src/pages/newAgent/agent-console-model.ts","lineNumber":148,"sourceCode":"\nfunction optionalString(value: unknown): string | undefined {\n  return typeof value === 'string' && value.trim() ? value.trim() : undefined;\n}\n\nfunction validateTransport(value: string): string {\n  const transport = required(value, 'transport');\n  if (!/^[0-9A-Za-z+-]{1,64}$/.test(transport)) {\n    throw new Error('transport must contain 1 to 64 letters, digits, +, or -');\n  }\n  return transport;\n}\n\nfunction endpointKey(uri: string, transport: string): string {\n  let parsed: URL;\n  try {\n    parsed = new URL(uri);\n  } catch {\n    throw new Error(`Invalid Endpoint URI: ${uri}`);\n  }\n  if (!parsed.protocol || !parsed.hostname || parsed.username || parsed.password || parsed.hash) {\n    throw new Error(`Invalid Endpoint URI: ${uri}`);\n  }\n  let port = parsed.port;\n  if (!port) {\n    if (parsed.protocol === 'http:' || parsed.protocol === 'ws:') {\n      port = '80';\n    } else if (parsed.protocol === 'https:' || parsed.protocol === 'wss:') {\n      port = '443';\n    } else {\n      throw new Error(`Invalid Endpoint URI: ${uri}`);\n    }\n  }\n  return `${parsed.hostname.toLowerCase()}@@${port}@@${transport}`;\n}\n\nfunction endpointSourceOrder(mode: EndpointSourceMode): AgentCallInterface['endpointSourceOrder'] {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/console-ui-next/src/pages/newAgent/agent-console-model.ts#L130-L166","documentation":"First of three Invalid Endpoint URI throws in endpointKey. This one fires when `new URL(uri)` itself throws — the input is not parseable as a URL at all (e.g. missing scheme, illegal characters). The URI must be an absolute URL with a scheme and host.","triggerScenarios":"User enters a bare host like 'localhost:8080' (no protocol), a relative path '/api', or a string with spaces/CRLF. The URL constructor cannot determine the protocol so it rejects the input.","commonSituations":"User omits the http:// or https:// scheme. User pastes a service name without protocol. Newline or whitespace embedded in the field.","solutions":["Provide a full absolute URL with a scheme: 'http://localhost:8080' or 'https://agent.example.com'.","Trim whitespace and strip trailing newlines before submitting.","Prepend 'http://' client-side if the user entered a bare host (confirm intent)."],"exampleFix":"// before\nuri = 'localhost:8080'\n\n// after\nuri = 'http://localhost:8080'","handlingStrategy":"validation","validationCode":"function checkAbsoluteUrl(uri) { try { const u = new URL(uri); if (!u.protocol || !u.hostname) throw 0; } catch { throw new Error('Provide a full URL with scheme and host'); } }","typeGuard":"function isAbsoluteUrl(uri: string): boolean {\n  try { const u = new URL(uri); return Boolean(u.protocol && u.hostname); } catch { return false; }\n}","tryCatchPattern":"try { endpointKey(uri, transport); } catch (e) {\n  if (/Invalid Endpoint URI/.test(e.message)) { toast.error('Enter a full URL like https://host:port'); }\n}","preventionTips":["Always include the scheme","Trim newlines","Prepend http:// for bare hosts"],"tags":["validation","endpoint","url","format"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}