Skip to content

Commit

Permalink
use TypedDict
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshFerge committed Jan 24, 2025
1 parent 4b63565 commit 9c631f2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/sentry/integrations/vercel/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import hmac
import logging
from collections.abc import Mapping
from typing import Any
from typing import Any, TypedDict

from django.http.request import HttpRequest
from django.http.response import HttpResponseBase
Expand Down Expand Up @@ -42,6 +42,12 @@ class MissingRepositoryError(IntegrationError):
pass


class _ReleasePayload(TypedDict):
version: str
projects: list[str]
refs: list[dict[str, str]]


def verify_signature(request):
signature = request.META.get("HTTP_X_VERCEL_SIGNATURE")
secret = options.get("vercel.client-secret")
Expand Down Expand Up @@ -95,7 +101,7 @@ def get_repository(meta: Mapping[str, str]) -> str:

def get_payload_and_token(
payload: Mapping[str, Any], organization_id: int, sentry_project_id: int
) -> tuple[dict[str, Any], str]:
) -> tuple[_ReleasePayload, str]:
meta = payload["deployment"]["meta"]

# look up the project so we can get the slug
Expand All @@ -121,7 +127,7 @@ def get_payload_and_token(
commit_sha = get_commit_sha(meta)
repository = get_repository(meta)

release_payload = {
release_payload: _ReleasePayload = {
"version": commit_sha,
"projects": [project.slug],
"refs": [{"repository": repository, "commit": commit_sha}],
Expand Down Expand Up @@ -371,9 +377,10 @@ def _deployment_created(self, external_id, request):
}
json_error = None

# create the basic release payload without refs
no_ref_payload = release_payload.copy()
del no_ref_payload["refs"]
no_ref_payload = {
"version": release_payload["version"],
"projects": release_payload["projects"],
}

with http.build_session() as session:
try:
Expand Down

0 comments on commit 9c631f2

Please sign in to comment.