Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/sentry/scm/private/providers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def get_pull_request_diff(
return {
"data": response.text,
"type": "github",
"raw": response.text,
"raw": {"data": response.text, "headers": dict(response.headers)},
"meta": _extract_response_meta(response),
}

Expand Down Expand Up @@ -933,7 +933,7 @@ def get_archive_link(
return {
"data": ArchiveLink(url=response.headers["Location"], headers={}),
"type": "github",
"raw": response.headers["Location"],
"raw": {"data": response.headers["Location"], "headers": dict(response.headers)},
"meta": _extract_response_meta(response),
}

Expand Down Expand Up @@ -1125,7 +1125,7 @@ def map_action[T](
return {
"data": fn(raw),
"type": "github",
"raw": raw,
"raw": {"data": raw, "headers": dict(response.headers)},
"meta": _extract_response_meta(response),
}

Expand All @@ -1143,6 +1143,6 @@ def map_paginated_action[T](
return {
"data": fn(raw),
"type": "github",
"raw": raw,
"raw": {"data": raw, "headers": dict(response.headers)},
"meta": meta,
}
8 changes: 4 additions & 4 deletions src/sentry/scm/private/providers/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def get_tree(
truncated=False,
),
type="gitlab",
raw=raw,
raw={"data": raw, "headers": None},
meta={},
)

Expand Down Expand Up @@ -390,7 +390,7 @@ def get_archive_link(
return ActionResult(
data=data,
type="gitlab",
raw=url,
raw={"data": url, "headers": None},
meta={},
)

Expand Down Expand Up @@ -597,7 +597,7 @@ def make_paginated_result[T](
return PaginatedActionResult(
data=[map_item(item) for item in raw_items],
type="gitlab",
raw=raw,
raw={"data": raw, "headers": None},
# No actual pagination for now
meta=PaginatedResponseMeta(next_cursor=None),
)
Expand All @@ -615,7 +615,7 @@ def make_result[T](
return ActionResult(
data=map_item(raw_item),
type="gitlab",
raw=raw,
raw={"data": raw, "headers": None},
meta={},
)

Expand Down
11 changes: 8 additions & 3 deletions src/sentry/scm/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from datetime import datetime
from typing import Any, Literal, Protocol, Required, TypedDict, runtime_checkable
from typing import Any, Literal, MutableMapping, Protocol, Required, TypedDict, runtime_checkable

type Action = Literal["check_run", "comment", "pull_request"]
type EventType = "CheckRunEvent" | "CommentEvent" | "PullRequestEvent"
Expand Down Expand Up @@ -217,6 +217,11 @@ class PullRequest(TypedDict):
base: PullRequestBranch


class RawResult(TypedDict):
headers: MutableMapping[str, str] | None
data: Any


class ActionResult[T](TypedDict):
"""Wraps a provider response with metadata and the original API payload.

Expand All @@ -230,7 +235,7 @@ class ActionResult[T](TypedDict):

data: T
type: ProviderName
raw: Any
raw: RawResult
meta: ResponseMeta


Expand All @@ -244,7 +249,7 @@ class PaginatedActionResult[T](TypedDict):

data: list[T]
type: ProviderName
raw: Any
raw: RawResult
meta: PaginatedResponseMeta


Expand Down
Loading
Loading