google/tsunami-security-scanner · error · ValueError
Name cannot be None.
Error message
Name cannot be None.
What it means
HttpHeaders.get_all() raises ValueError('Name cannot be None.') when the requested header name is None. It performs an exact lookup then a canonicalized-name fallback, so a non-None (even unknown) name safely returns [].
Solutions
- Check the name is not None before calling get_all/get.
- Provide a default header name at the call site (e.g. name or 'Content-Type').
- Fix upstream parsing so a missing header yields a string, not None.
Example fix
// before
values = http_headers.get(header_name)
// after
if header_name is not None:
values = http_headers.get(header_name)
else:
values = [] Defensive patterns
Strategy: type-guard
Validate before calling
assert header_name is not None, "header name is required"
Type guard
def safe_get(headers, name, default=None):
return headers.get_all(name) if name is not None else default Try / catch
try:
values = http_headers.get(name)
except ValueError:
values = [] Prevention
- Never pass variables that can be None as header names.
- Default missing header names with `or ''`/sentinel before lookup.
- Check parsing code that produces header names for None results.
When it happens
Trigger: Calling http_headers.get(None) or get_all(None), typically when the header name comes from an unset variable, a failed regex group, or a config lookup returning None, at http_headers.py:45.
Common situations: Plugins reading headers from a mapping that returned None for a missing key; passing the result of a failed parse directly as the header name; iterating optional header names without defaults.
Related errors
- Value cannot be None.
- Illegal header name .
- Illegal header value
- Url cannot be None.
- A request body is not allowed for HTTP GET/HEAD request.
AI-assisted analysis of google/tsunami-security-scanner@363ba87b35 (2026-09-13).
Data as JSON: /api/errors/ad75c538c949b3a9.
Report an issue: GitHub.
Appendix: source
Thrown at plugin_server/py/common/net/http/http_headers.py:45
"""Get the first value for a specified HTTP field name."""
values = self.get_all(name)
if not values:
return None
return values[0]
def get_all(self, name: str) -> list[str]:
"""Get all values for a specified HTTP field name.
Values are in the order they were added to the builder.
Args:
name: header name
Returns:
List of matched header values.
"""
if name is None:
raise ValueError('Name cannot be None.')
values = self.raw_headers.get(name, [])
if values:
return values
canonicalized_name = _canonicalize(name)
return self.raw_headers.get(canonicalized_name, [])
@classmethod
def builder(cls) -> 'Builder':
return Builder()
class Builder:
"""Builder class to create HTTP headers object.
Attributes:
http_headers: Collection of header field names and corresponding values.
"""
# RFC 2616 section 4.2.View on GitHub (pinned to 363ba87b35)