-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
The set_headers and set_headers_async methods currently assume that response.set_header or response.headers assignment always succeeds.
In practice, especially when supporting multiple frameworks (e.g., FastAPI, Flask, Django), setting headers may:
- Fail silently,
- Raise unexpected exceptions (e.g.,
TypeError,ValueError), - Encounter immutable response objects.
Affected Code
set_header(header_name, header_value)— Line 247, Line 275, Line 278response.headers[header_name] = header_value— Line 251, Line 282
Recommendation
- Wrap all
set_headercalls insidetry-exceptblocks. - Capture at minimum:
TypeErrorValueError- Any web framework-specific exceptions (e.g., attribute errors for immutable headers).
- Log the error or raise a custom error with a meaningful message.
- Ensure header application failures are either safely skipped or fail-fast based on the criticality.
Metadata
Metadata
Assignees
Labels
No labels