A request header is read with [...], which fails the request when the client did not send it
What it finds
request.headers["X-Token"] raises when the header is missing, and Flask answers with a bare 400 while Django's request.META[...] gives a 500. Headers are under the client's control; .get() with a default handles the missing case on purpose.
From the rule's source, request_header_subscript.rs.
from flask import request def token(): a = request.headers["X-Token"]tx0 reports: a missing header makes this lookup fail b = request.headers.get("X-Token") c = request.META["HTTP_HOST"]tx0 reports: a missing header return a, b, c Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:request-header-subscript" = "note"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:request-header-subscript] reason="..."tx0 explain tx0/python:request-header-subscript shows the same in the terminal. Found a false positive? Report it.