{"record":{"id":"49af755b0d6b8b8a","repo":"langchain-ai/deepagents","slug":"remote-source-has-an-invalid-port","errorCode":null,"errorMessage":"remote source has an invalid port","messagePattern":"remote source has an invalid port","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/configuration/types.py","lineNumber":88,"sourceCode":"        msg = \"remote source is not a valid URL\"\n        raise ValueError(msg) from exc\n    if not source.isascii():\n        msg = \"remote source must contain only ASCII URI characters\"\n        raise ValueError(msg)\n    if parsed.scheme.lower() != \"https\" or not parsed.hostname:\n        msg = \"remote source must be an absolute HTTPS URL\"\n        raise ValueError(msg)\n    if parsed.username is not None or parsed.password is not None:\n        msg = \"remote source must not contain credentials\"\n        raise ValueError(msg)\n    if parsed.query or parsed.fragment:\n        msg = \"remote source must not contain a query string or fragment\"\n        raise ValueError(msg)\n    try:\n        port = parsed.port\n    except ValueError as exc:\n        msg = \"remote source has an invalid port\"\n        raise ValueError(msg) from exc\n    host = parsed.hostname.rstrip(\".\")\n    netloc = f\"[{host}]\" if \":\" in host else host\n    if port is not None:\n        netloc = f\"{netloc}:{port}\"\n    return parsed._replace(scheme=\"https\", netloc=netloc).geturl()\n\n\n@dataclass(frozen=True, slots=True)\nclass ProviderStatus:\n    \"\"\"Health and safe diagnostic detail for one provider.\"\"\"\n\n    name: str\n    path: Path | None\n    health: ProviderHealth\n    detail: str | None = None\n    remote_source: str | None = field(default=None, kw_only=True)\n    \"\"\"Validated URL this status came from, when `path` is only a trust anchor.\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/configuration/types.py#L70-L106","documentation":"Raised by `_validate_remote_source_url` when `parsed.port` raises ValueError, i.e. the URL contains a syntactically invalid port (non-numeric or out of range, e.g. 'https://example.com:99999/x' or 'https://example.com:abc/x'). The library re-raises with a clearer message before reconstructing the normalized netloc.","triggerScenarios":"Constructing the remote-source dataclass with a URL whose port is non-numeric, empty after ':', or above 65535 — the urllib.parse `.port` accessor raises and the code re-raises 'remote source has an invalid port'.","commonSituations":"Typos like 'https:/example.com:8443a/...' from hand-editing; double colons ('https://example.com::443/'); pasting 'host:port' pairs where the port field contains a service name ('https://example.com:https/').","solutions":["Correct or remove the port — omit it entirely for the default HTTPS port 443","Ensure the port is a plain integer between 1 and 65535","Check for doubled colons or stray characters around the port in the URL"],"exampleFix":"// before\nRemoteSource(source=\"https://example.com:99999/config.toml\")\n// after\nRemoteSource(source=\"https://example.com:8443/config.toml\")","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\n\ndef has_valid_port(source: str) -> bool:\n    try:\n        urlparse(source).port\n    except ValueError:\n        return False\n    return True\n\nif not has_valid_port(src):\n    raise ConfigError(f\"invalid port in remote source: {src!r}\")","typeGuard":"def is_parseable_port_url(value: str) -> bool:\n    try:\n        urlparse(value).port\n        return True\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    RemoteSource(source=src)\nexcept ValueError as exc:\n    if \"invalid port\" in str(exc):\n        raise ConfigError(f\"fix the port in remote source: {src!r}\") from exc\n    raise","preventionTips":["Omit the port when using the default 443","Check ports are integers 1-65535 after hand edits","Beware doubled colons from template substitution"],"tags":["validation","url","port"],"backgroundTag":"invalid-remote-source-url","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}