{"record":{"id":"4f8304247124a833","repo":"google/tsunami-security-scanner","slug":"url-cannot-be-none","errorCode":null,"errorMessage":"Url cannot be None.","messagePattern":"Url cannot be None\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"plugin_server/py/common/net/http/http_request.py","lineNumber":13,"sourceCode":"\"\"\"HTTP request utility.\"\"\"\n\nfrom typing import Optional\n\nfrom common.net.http.http_headers import Builder as HttpHeadersBuilder\nfrom common.net.http.http_headers import HttpHeaders\nfrom common.net.http.http_method import HttpMethod\n\n\ndef check_url_argument(func):\n  def wrapper(cls, url):\n    if not url:\n      raise ValueError('Url cannot be None.')\n    return func(cls, url)\n  return wrapper\n\n\nclass HttpRequest:\n  \"\"\"HTTP request utility class.\n\n  Please use Builder() to create instances of this class.\n\n  Attributes:\n    method: The HTTP request type.\n    url: String address of the request.\n    headers: The HTTP request headers in key/value pairs.\n    body: The HTTP body could be empty per the request type. GET and\n      HEAD request types must have empty request_body.\n  \"\"\"\n\n  def __init__(self):","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/google/tsunami-security-scanner/blob/363ba87b3543f8ae8e4304d3416818f03da7f262/plugin_server/py/common/net/http/http_request.py#L1-L31","documentation":"The check_url_argument decorator wraps HttpRequest factory functions and rejects falsy URLs before the underlying constructor runs. This library throws it so a request object is never created with a missing URL, which would fail later at send time with a less obvious error.","triggerScenarios":"Calling an HttpRequest builder with url=None, url='' or any falsy value, e.g. HttpRequest.of(None) or a builder whose url parameter is sourced from an unset config/CLI field.","commonSituations":"Target URL read from an environment variable or scan config that is unset; a plugin computing the URL from request data that was absent; refactors renaming the url parameter so positional args shifted.","solutions":["Log/inspect the url value at the call site; trace where it is sourced from","Guard the call: only build the request if the url is a non-empty string","Fix the configuration/env var that should supply the target URL","Provide a sensible default or fail fast upstream with a clearer message"],"exampleFix":"// before\nreq = HttpRequest.of(config.target_url)  # may be None\n// after\nif not config.target_url:\n  raise ValueError('target_url must be configured before sending a request')\nreq = HttpRequest.of(config.target_url)","handlingStrategy":"validation","validationCode":"def build_request_checked(cls, url):\n    if not isinstance(url, str) or not url:\n        raise ValueError('target URL must be a non-empty string')\n    return HttpRequest.of(url)","typeGuard":"def has_url(url) -> bool:\n    return isinstance(url, str) and bool(url.strip())","tryCatchPattern":"try:\n    req = HttpRequest.of(url)\nexcept ValueError:\n    logging.error('Missing target URL; check config/env')\n    return None","preventionTips":["Validate scan config URLs at startup, before any request building","Use explicit None checks rather than truthiness when defaults like '' are meaningful","Keep url parameter ordering stable when calling builders positionally"],"tags":["python","http","url","null-check"],"backgroundTag":"missing-required-argument","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"}