Skip to content

Commit 1282ee5

Browse files
fix: fall back to base query when namespace doesn't match any owner
Enterprise system hooks can have path_with_namespace that doesn't match the Codecov Owner username (e.g. repo owned by an org, not the user in the path). Try the narrowed query first, fall back to the original. Made-with: Cursor
1 parent afea6ff commit 1282ee5

File tree

1 file changed

+8
-3
lines changed
  • apps/codecov-api/webhook_handlers/views

1 file changed

+8
-3
lines changed

apps/codecov-api/webhook_handlers/views/gitlab.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,17 @@ def post(self, request, *args, **kwargs):
9191

9292
try:
9393
if owner:
94-
repo = get_object_or_404(
95-
Repository,
94+
repo = Repository.objects.filter(
9695
author__service=self.service_name,
9796
author__username=owner,
9897
service_id=project_id,
99-
)
98+
).first()
99+
if not repo:
100+
repo = get_object_or_404(
101+
Repository,
102+
author__service=self.service_name,
103+
service_id=project_id,
104+
)
100105
else:
101106
repo = get_object_or_404(
102107
Repository,

0 commit comments

Comments
 (0)