ref(sentry-apps): extract webhook header parsing and masking helpers#119529
Merged
cvxluo merged 1 commit intoJul 13, 2026
Merged
Conversation
Co-authored-by: Claude <noreply@anthropic.com>
Comment on lines
+8
to
+9
| for header in webhook_headers: | ||
| name, separator, value = header.partition(":") |
Contributor
There was a problem hiding this comment.
Bug: The parse_custom_headers function will crash with a TypeError if webhook_headers is None, which can happen for older SentryApp database records.
Severity: HIGH
Suggested Fix
Add a guard to the parse_custom_headers function to handle cases where webhook_headers is None. A simple way to do this is to default to an empty list, for example: for header in webhook_headers or []:. This restores the safe behavior that existed before the refactor.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/sentry/sentry_apps/utils/headers.py#L8-L9
Potential issue: The function `parse_custom_headers` does not handle `None` values for
its `webhook_headers` argument. This can lead to a `TypeError` when the function
attempts to iterate over `None`. The `webhook_headers` field can be `None` for
`SentryApp` records that were created before the database migration that added this
field, as the migration did not backfill existing rows, leaving them as `NULL` in the
database. The original code handled this possibility with `or []`, but this safeguard
was removed during refactoring, introducing a regression.
Also affects:
src/sentry/sentry_apps/api/serializers/app_platform_event.py:114~114
Did we get this right? 👍 / 👎 to inform future reviews.
Contributor
Author
There was a problem hiding this comment.
pretty sure the column defaults to [] rather than null
billyvg
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move logic for sentry app custom headers reading + masking into its own file, so they can be used by
src/sentry/sentry_apps/external_requests/utils.py.