google/tsunami-security-scanner · error · ValueError

URI scheme should be one of the following: 'http', 'https'

Error message

URI scheme should be one of the following: 'http', 'https'

What it means

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.

Solutions

  1. Normalize with scheme = scheme.lower().strip() before validating.
  2. Reject or skip URLs whose scheme is not http/https before calling build_uri_network_service.
  3. If the endpoint truly uses another scheme, handle it outside this helper.

Example fix

// before
network_service_utils.validate_scheme(url.split(':')[0])
// after
scheme = url.split(':')[0].lower()
if scheme in ('http', 'https'):
    network_service_utils.validate_scheme(scheme)
Defensive patterns

Strategy: validation

Validate before calling

scheme = urllib.parse.urlparse(url).scheme.lower()
if scheme not in ("http", "https"): raise SkipUrl(url)

Type guard

def is_web_scheme(scheme: str) -> bool:
    return isinstance(scheme, str) and scheme.lower() in ("http", "https")

Try / catch

try:
    network_service_utils.validate_scheme(scheme)
except ValueError as e:
    logging.warning("Ignoring non-web URL: %s", e)

Prevention

When it happens

Trigger: 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.

Common situations: Passing user-supplied URLs with unexpected schemes into plugins; lowercasing missed before validation; test fixtures using file:// URLs.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of google/tsunami-security-scanner@363ba87b35 (2026-09-13). Data as JSON: /api/errors/9b7fca1e738e7cc8. Report an issue: GitHub.

Appendix: source

Thrown at plugin_server/py/common/data/network_service_utils.py:203


def sanitize_port(port: Optional[int], scheme: str) -> int:
  if isinstance(port, type(None)):
    return get_port(-1, scheme)
  return get_port(port, scheme)


def get_port(port: int, scheme: str) -> int:
  if port >= 0:
    return port
  return 80 if scheme == "http" else 443


def validate_scheme(scheme: str) -> None:
  if scheme == "http" or scheme == "https":
    pass
  else:
    raise ValueError(
        "URI scheme should be one of the following: 'http', 'https'")

View on GitHub (pinned to 363ba87b35)