Skip to content

Commit c36a028

Browse files
authored
fix(detectors): Another potential TypeError (#95360)
The defensive check `len(query_pair)` can raise a `TypeError` if `query_pair` is a truthy non-sequence type (e.g., integers, booleans). This occurs with malformed input data, causing a crash by replacing a potential "not subscriptable" error with a "has no len()" error. The fix, intended to prevent one `TypeError`, introduces another. Reported [here](#95356 (review)).
1 parent 4874377 commit c36a028

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/sentry/performance_issues/detectors/sql_injection_detector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def extract_request_data(self, event: dict[str, Any]) -> None:
9292

9393
for query_pair in request_data:
9494
# Skip None values or pairs that don't have at least 2 elements
95-
if not query_pair or len(query_pair) < 2:
95+
if not query_pair or not isinstance(query_pair, Sequence) or len(query_pair) < 2:
9696
continue
9797
query_value = query_pair[1]
9898
query_key = query_pair[0]

0 commit comments

Comments
 (0)