{"record":{"id":"9b7fca1e738e7cc8","repo":"google/tsunami-security-scanner","slug":"uri-scheme-should-be-one-of-the-following-http-https","errorCode":null,"errorMessage":"URI scheme should be one of the following: 'http', 'https'","messagePattern":"URI scheme should be one of the following: 'http', 'https'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"plugin_server/py/common/data/network_service_utils.py","lineNumber":203,"sourceCode":"\n\ndef sanitize_port(port: Optional[int], scheme: str) -> int:\n  if isinstance(port, type(None)):\n    return get_port(-1, scheme)\n  return get_port(port, scheme)\n\n\ndef get_port(port: int, scheme: str) -> int:\n  if port >= 0:\n    return port\n  return 80 if scheme == \"http\" else 443\n\n\ndef validate_scheme(scheme: str) -> None:\n  if scheme == \"http\" or scheme == \"https\":\n    pass\n  else:\n    raise ValueError(\n        \"URI scheme should be one of the following: 'http', 'https'\")\n","sourceCodeStart":185,"sourceCodeEnd":205,"githubUrl":"https://github.com/google/tsunami-security-scanner/blob/363ba87b3543f8ae8e4304d3416818f03da7f262/plugin_server/py/common/data/network_service_utils.py#L185-L205","documentation":"validate_scheme() in network_service_utils.py rejects any URI scheme other than 'http' or 'https', raising ValueError. It is used when constructing a NetworkService/URI from a URL so only web schemes are accepted.","triggerScenarios":"Calling validate_scheme with 'ftp://...', 'file://...', an empty scheme, or a scheme with trailing characters (e.g. 'HTTP' uppercase is rejected since comparison is case-sensitive), at network_service_utils.py:203.","commonSituations":"Passing user-supplied URLs with unexpected schemes into plugins; lowercasing missed before validation; test fixtures using file:// URLs.","solutions":["Normalize with scheme = scheme.lower().strip() before validating.","Reject or skip URLs whose scheme is not http/https before calling build_uri_network_service.","If the endpoint truly uses another scheme, handle it outside this helper."],"exampleFix":"// before\nnetwork_service_utils.validate_scheme(url.split(':')[0])\n// after\nscheme = url.split(':')[0].lower()\nif scheme in ('http', 'https'):\n    network_service_utils.validate_scheme(scheme)","handlingStrategy":"validation","validationCode":"scheme = urllib.parse.urlparse(url).scheme.lower()\nif scheme not in (\"http\", \"https\"): raise SkipUrl(url)","typeGuard":"def is_web_scheme(scheme: str) -> bool:\n    return isinstance(scheme, str) and scheme.lower() in (\"http\", \"https\")","tryCatchPattern":"try:\n    network_service_utils.validate_scheme(scheme)\nexcept ValueError as e:\n    logging.warning(\"Ignoring non-web URL: %s\", e)","preventionTips":["Lowercase and strip schemes before validation.","Validate user-supplied URLs at the input boundary.","Restrict accepted URLs to http/https upstream of plugin logic."],"tags":["python","url","scheme","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"363ba87b3543f8ae8e4304d3416818f03da7f262","analyzedAt":"2026-09-13T01:50:53.990Z","contentChangedAt":"2026-09-13T01:50:53.990Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}