Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 24.10.1 #845

Merged
merged 3 commits into from
Oct 1, 2024
Merged

Release 24.10.1 #845

merged 3 commits into from
Oct 1, 2024

Conversation

codecov-releaser
Copy link
Contributor

Release PR for 24.10.1
I've updated the version name and committed: b4e95d0.

@codecov-notifications
Copy link

codecov-notifications bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.26%. Comparing base (2fca394) to head (d3831be).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #845   +/-   ##
=======================================
  Coverage   96.26%   96.26%           
=======================================
  Files         814      814           
  Lines       18680    18680           
=======================================
  Hits        17982    17982           
  Misses        698      698           
Flag Coverage Δ
unit 92.52% <ø> (ø)
unit-latest-uploader 92.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Oct 1, 2024

This PR includes changes to shared. Please review them here: codecov/shared@9130171...a97eb0a

@codecov-qa
Copy link

codecov-qa bot commented Oct 1, 2024

❌ 6 Tests Failed:

Tests completed Failed Passed Skipped
2323 6 2317 6
View the top 3 failed tests by shortest run time
core.tests.test_managers.RepositoryQuerySetTests test_get_or_create_from_github_repo_data
Stack Traces | 0.022s run time
self = &lt;core.tests.test_managers.RepositoryQuerySetTests testMethod=test_get_or_create_from_github_repo_data&gt;

    def test_get_or_create_from_github_repo_data(self):
        owner = OwnerFactory()
    
        with self.subTest("doesnt crash when fork but no parent"):
            repo_data = {
                "id": 45,
                "default_branch": "main",
                "private": True,
                "name": "test",
                "fork": True,
            }
    
&gt;           repo, created = Repository.objects.get_or_create_from_git_repo(
                repo_data, owner
            )

core/tests/test_managers.py:83: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12.../django_apps/core/managers.py:402: in get_or_create_from_git_repo
    return self.get_queryset().get_or_create_from_git_repo(*args, **kwargs)
.../local/lib/python3.12.../django_apps/core/managers.py:309: in get_or_create_from_git_repo
    log.info(
.../local/lib/python3.12/logging/__init__.py:1539: in info
    self._log(INFO, msg, args, **kwargs)
.../local/lib/python3.12/logging/__init__.py:1682: in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;Logger __name__ (INFO)&gt;, name = '__name__', level = 20
fn = '.../local/lib/python3.12.../django_apps/core/managers.py'
lno = 309
msg = '[GetOrCreateFromGitRepo] - Repo successfully updated or created'
args = (), exc_info = None, func = 'get_or_create_from_git_repo'
extra = {'author': 944, 'created': True, 'defaults': {'branch': 'main', 'name': 'test', 'private': True, 'service_id': 45}, 'name': 'test', ...}
sinfo = None

    def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
                   func=None, extra=None, sinfo=None):
        """
        A factory method which can be overridden in subclasses to create
        specialized LogRecords.
        """
        rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
                             sinfo)
        if extra is not None:
            for key in extra:
                if (key in ["message", "asctime"]) or (key in rv.__dict__):
&gt;                   raise KeyError("Attempt to overwrite %r in LogRecord" % key)
E                   KeyError: "Attempt to overwrite 'name' in LogRecord"

.../local/lib/python3.12/logging/__init__.py:1656: KeyError
api.internal.tests.test_repo_accessors.RepositoryAccessorsTestCase test_fetch_and_create_repo
Stack Traces | 0.052s run time
self = &lt;tests.test_repo_accessors.RepositoryAccessorsTestCase testMethod=test_fetch_and_create_repo&gt;
mocked_repo_provider_service = &lt;MagicMock name='get_by_name' id='140421181471152'&gt;

    @patch("services.repo_providers.RepoProviderService.get_by_name")
    def test_fetch_and_create_repo(self, mocked_repo_provider_service):
        git_repo_response = {
            "repo": {
                "name": "new-repo",
                "branch": "default",
                "private": True,
                "service_id": "7293846",
                "fork": {
                    "repo": {
                        "name": "fork-repo",
                        "branch": "master",
                        "private": True,
                        "service_id": "4720394",
                    },
                    "owner": {"username": "fork_owner", "service_id": "0956093"},
                },
            },
            "owner": {"username": "new-org", "service_id": "9437469"},
        }
    
        class MockedRepoService:
            async def get_repository(self):
                return git_repo_response
    
        mocked_repo_provider_service.return_value = MockedRepoService()
    
&gt;       repo = RepoAccessors.fetch_from_git_and_create_repo(
            self, self.user, "new-repo", "new-org", "github"
        )

.../internal/tests/test_repo_accessors.py:73: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../shared/repo/repository_accessors.py:75: in fetch_from_git_and_create_repo
    return Repository.objects.get_or_create_from_git_repo(
.../local/lib/python3.12.../django_apps/core/managers.py:402: in get_or_create_from_git_repo
    return self.get_queryset().get_or_create_from_git_repo(*args, **kwargs)
.../local/lib/python3.12.../django_apps/core/managers.py:309: in get_or_create_from_git_repo
    log.info(
.../local/lib/python3.12/logging/__init__.py:1539: in info
    self._log(INFO, msg, args, **kwargs)
.../local/lib/python3.12/logging/__init__.py:1682: in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;Logger __name__ (INFO)&gt;, name = '__name__', level = 20
fn = '.../local/lib/python3.12.../django_apps/core/managers.py'
lno = 309
msg = '[GetOrCreateFromGitRepo] - Repo successfully updated or created'
args = (), exc_info = None, func = 'get_or_create_from_git_repo'
extra = {'author': 101, 'created': True, 'defaults': {'branch': 'default', 'name': 'new-repo', 'private': True, 'service_id': '7293846'}, 'name': 'new-repo', ...}
sinfo = None

    def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
                   func=None, extra=None, sinfo=None):
        """
        A factory method which can be overridden in subclasses to create
        specialized LogRecords.
        """
        rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
                             sinfo)
        if extra is not None:
            for key in extra:
                if (key in ["message", "asctime"]) or (key in rv.__dict__):
&gt;                   raise KeyError("Attempt to overwrite %r in LogRecord" % key)
E                   KeyError: "Attempt to overwrite 'name' in LogRecord"

.../local/lib/python3.12/logging/__init__.py:1656: KeyError
webhook_handlers.tests.test_github_enterprise.GithubEnterpriseWebhookHandlerTests test_repo_creation_doesnt_crash_for_forked_repo
Stack Traces | 0.082s run time
self = &lt;webhook_handlers.views.github.GithubEnterpriseWebhookHandler object at 0x7fb65888ccb0&gt;
request = &lt;rest_framework.request.Request: POST '/webhooks/github_enterprise'&gt;

    def _get_repo(self, request):
        """
        Attempts to fetch the repo first via the index on o(wnerid, service_id),
        then naively on service, service_id if that fails.
        """
        repo_data = self.request.data.get("repository", {})
        repo_service_id = repo_data.get("id")
        owner_service_id = repo_data.get("owner", {}).get("id")
        repo_slug = repo_data.get("full_name")
    
        try:
            owner = Owner.objects.get(
                service=self.service_name, service_id=owner_service_id
            )
        except Owner.DoesNotExist:
            log.info(
                f"Error fetching owner with service_id {owner_service_id}, "
                f"using repository service id to get repo",
                extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
            )
            try:
                log.info(
                    "Unable to find repository owner, fetching repo with service, service_id",
                    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
                )
                return Repository.objects.get(
                    author__service=self.service_name, service_id=repo_service_id
                )
            except Repository.DoesNotExist:
                log.info(
                    "Received event for non-existent repository",
                    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
                )
                raise NotFound("Repository does not exist")
        else:
            try:
                log.debug(
                    "Found repository owner, fetching repo with ownerid, service_id",
                    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
                )
&gt;               return Repository.objects.get(
                    author__ownerid=owner.ownerid, service_id=repo_service_id
                )

webhook_handlers/views/github.py:145: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;RepositoryQuerySet []&gt;, args = ()
kwargs = {'author__ownerid': 2745, 'service_id': 506003}
clone = &lt;RepositoryQuerySet []&gt;, limit = 21, num = 0

    def get(self, *args, **kwargs):
        """
        Perform the query and return a single object matching the given
        keyword arguments.
        """
        if self.query.combinator and (args or kwargs):
            raise NotSupportedError(
                "Calling QuerySet.get(...) with filters after %s() is not "
                "supported." % self.query.combinator
            )
        clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
        if self.query.can_filter() and not self.query.distinct_fields:
            clone = clone.order_by()
        limit = None
        if (
            not clone.query.select_for_update
            or connections[clone.db].features.supports_select_for_update_with_limit
        ):
            limit = MAX_GET_RESULTS
            clone.query.set_limits(high=limit)
        num = len(clone)
        if num == 1:
            return clone._result_cache[0]
        if not num:
&gt;           raise self.model.DoesNotExist(
                "%s matching query does not exist." % self.model._meta.object_name
            )
E           shared.django_apps.core.models.Repository.DoesNotExist: Repository matching query does not exist.

.../local/lib/python3.12.../db/models/query.py:637: DoesNotExist

During handling of the above exception, another exception occurred:

self = &lt;webhook_handlers.tests.test_github_enterprise.GithubEnterpriseWebhookHandlerTests testMethod=test_repo_creation_doesnt_crash_for_forked_repo&gt;

    def test_repo_creation_doesnt_crash_for_forked_repo(self):
        owner = OwnerFactory(
            integration_id=4850403,
            service_id=97968493,
            service=Service.GITHUB_ENTERPRISE.value,
        )
&gt;       self._post_event_data(
            event=GitHubWebhookEvents.REPOSITORY,
            data={
                "action": "publicized",
                "repository": {
                    "id": 506003,
                    "name": "testrepo",
                    "private": False,
                    "default_branch": "master",
                    "owner": {"id": owner.service_id},
                    "fork": True,
                    "parent": {
                        "name": "mainrepo",
                        "language": "python",
                        "id": 7940284,
                        "private": False,
                        "default_branch": "master",
                        "owner": {"id": 8495712939, "login": "alogin"},
                    },
                },
            },
        )

webhook_handlers/tests/test_github_enterprise.py:1162: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webhook_handlers/tests/test_github_enterprise.py:48: in _post_event_data
    return self.client.post(
.../local/lib/python3.12.............../site-packages/rest_framework/test.py:295: in post
    response = super().post(
.../local/lib/python3.12.............../site-packages/rest_framework/test.py:209: in post
    return self.generic('POST', path, data, content_type, **extra)
.../local/lib/python3.12.............../site-packages/rest_framework/test.py:233: in generic
    return super().generic(
.../local/lib/python3.12.../django/test/client.py:609: in generic
    return self.request(**r)
.../local/lib/python3.12.............../site-packages/rest_framework/test.py:285: in request
    return super().request(**kwargs)
.../local/lib/python3.12.............../site-packages/rest_framework/test.py:237: in request
    request = super().request(**kwargs)
.../local/lib/python3.12.../django/test/client.py:891: in request
    self.check_exception(response)
.../local/lib/python3.12.../django/test/client.py:738: in check_exception
    raise exc_value
.../local/lib/python3.12.../core/handlers/exception.py:55: in inner
    response = get_response(request)
.../local/lib/python3.12.../core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
.../local/lib/python3.12.../integrations/django/views.py:89: in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
.../local/lib/python3.12.../views/decorators/csrf.py:56: in wrapper_view
    return view_func(*args, **kwargs)
.../local/lib/python3.12.../views/generic/base.py:104: in view
    return self.dispatch(request, *args, **kwargs)
.../local/lib/python3.12............/site-packages/rest_framework/views.py:509: in dispatch
    response = self.handle_exception(exc)
.../local/lib/python3.12............/site-packages/rest_framework/views.py:469: in handle_exception
    self.raise_uncaught_exception(exc)
.../local/lib/python3.12............/site-packages/rest_framework/views.py:480: in raise_uncaught_exception
    raise exc
.../local/lib/python3.12............/site-packages/rest_framework/views.py:506: in dispatch
    response = handler(request, *args, **kwargs)
webhook_handlers/views/github.py:749: in post
    return handler(request, *args, **kwargs)
webhook_handlers/views/github.py:170: in repository
    action, repo = self.request.data.get("action"), self._get_repo(request)
webhook_handlers/views/github.py:156: in _get_repo
    return Repository.objects.get_or_create_from_git_repo(
.../local/lib/python3.12.../django_apps/core/managers.py:402: in get_or_create_from_git_repo
    return self.get_queryset().get_or_create_from_git_repo(*args, **kwargs)
.../local/lib/python3.12.../django_apps/core/managers.py:309: in get_or_create_from_git_repo
    log.info(
.../local/lib/python3.12/logging/__init__.py:1539: in info
    self._log(INFO, msg, args, **kwargs)
.../local/lib/python3.12/logging/__init__.py:1682: in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;Logger __name__ (INFO)&gt;, name = '__name__', level = 20
fn = '.../local/lib/python3.12.../django_apps/core/managers.py'
lno = 309
msg = '[GetOrCreateFromGitRepo] - Repo successfully updated or created'
args = (), exc_info = None, func = 'get_or_create_from_git_repo'
extra = {'author': 2745, 'created': True, 'defaults': {'branch': 'master', 'name': 'testrepo', 'private': False, 'service_id': 506003}, 'name': 'testrepo', ...}
sinfo = None

    def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
                   func=None, extra=None, sinfo=None):
        """
        A factory method which can be overridden in subclasses to create
        specialized LogRecords.
        """
        rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
                             sinfo)
        if extra is not None:
            for key in extra:
                if (key in ["message", "asctime"]) or (key in rv.__dict__):
&gt;                   raise KeyError("Attempt to overwrite %r in LogRecord" % key)
E                   KeyError: "Attempt to overwrite 'name' in LogRecord"

.../local/lib/python3.12/logging/__init__.py:1656: KeyError

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Copy link

codecov-public-qa bot commented Oct 1, 2024

Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time.

❌ Failed Test Results:

Completed 2329 tests with 6 failed, 2317 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: api.internal.tests.test_repo_accessors.RepositoryAccessorsTestCase
    Test name: test_fetch_and_create_repo

    self = <tests.test_repo_accessors.RepositoryAccessorsTestCase testMethod=test_fetch_and_create_repo>
    mocked_repo_provider_service = <MagicMock name='get_by_name' id='140421181471152'>

    @patch("services.repo_providers.RepoProviderService.get_by_name")
    def test_fetch_and_create_repo(self, mocked_repo_provider_service):
    git_repo_response = {
    "repo": {
    "name": "new-repo",
    "branch": "default",
    "private": True,
    "service_id": "7293846",
    "fork": {
    "repo": {
    "name": "fork-repo",
    "branch": "master",
    "private": True,
    "service_id": "4720394",
    },
    "owner": {"username": "fork_owner", "service_id": "0956093"},
    },
    },
    "owner": {"username": "new-org", "service_id": "9437469"},
    }

    class MockedRepoService:
    async def get_repository(self):
    return git_repo_response

    mocked_repo_provider_service.return_value = MockedRepoService()

    > repo = RepoAccessors.fetch_from_git_and_create_repo(
    self, self.user, "new-repo", "new-org", "github"
    )

    .../internal/tests/test_repo_accessors.py:73:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../shared/repo/repository_accessors.py:75: in fetch_from_git_and_create_repo
    return Repository.objects.get_or_create_from_git_repo(
    .../local/lib/python3.12.../django_apps/core/managers.py:402: in get_or_create_from_git_repo
    return self.get_queryset().get_or_create_from_git_repo(*args, **kwargs)
    .../local/lib/python3.12.../django_apps/core/managers.py:309: in get_or_create_from_git_repo
    log.info(
    .../local/lib/python3.12/logging/__init__.py:1539: in info
    self._log(INFO, msg, args, **kwargs)
    .../local/lib/python3.12/logging/__init__.py:1682: in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args,
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <Logger __name__ (INFO)>, name = '__name__', level = 20
    fn = '.../local/lib/python3.12.../django_apps/core/managers.py'
    lno = 309
    msg = '[GetOrCreateFromGitRepo] - Repo successfully updated or created'
    args = (), exc_info = None, func = 'get_or_create_from_git_repo'
    extra = {'author': 101, 'created': True, 'defaults': {'branch': 'default', 'name': 'new-repo', 'private': True, 'service_id': '7293846'}, 'name': 'new-repo', ...}
    sinfo = None

    def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
    func=None, extra=None, sinfo=None):
    """
    A factory method which can be overridden in subclasses to create
    specialized LogRecords.
    """
    rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
    sinfo)
    if extra is not None:
    for key in extra:
    if (key in ["message", "asctime"]) or (key in rv.__dict__):
    > raise KeyError("Attempt to overwrite %r in LogRecord" % key)
    E KeyError: "Attempt to overwrite 'name' in LogRecord"

    .../local/lib/python3.12/logging/__init__.py:1656: KeyError
  • Class name: core.tests.test_managers.RepositoryQuerySetTests
    Test name: test_get_or_create_from_github_repo_data

    self = <core.tests.test_managers.RepositoryQuerySetTests testMethod=test_get_or_create_from_github_repo_data>

    def test_get_or_create_from_github_repo_data(self):
    owner = OwnerFactory()

    with self.subTest("doesnt crash when fork but no parent"):
    repo_data = {
    "id": 45,
    "default_branch": "main",
    "private": True,
    "name": "test",
    "fork": True,
    }

    > repo, created = Repository.objects.get_or_create_from_git_repo(
    repo_data, owner
    )

    core/tests/test_managers.py:83:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12.../django_apps/core/managers.py:402: in get_or_create_from_git_repo
    return self.get_queryset().get_or_create_from_git_repo(*args, **kwargs)
    .../local/lib/python3.12.../django_apps/core/managers.py:309: in get_or_create_from_git_repo
    log.info(
    .../local/lib/python3.12/logging/__init__.py:1539: in info
    self._log(INFO, msg, args, **kwargs)
    .../local/lib/python3.12/logging/__init__.py:1682: in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args,
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <Logger __name__ (INFO)>, name = '__name__', level = 20
    fn = '.../local/lib/python3.12.../django_apps/core/managers.py'
    lno = 309
    msg = '[GetOrCreateFromGitRepo] - Repo successfully updated or created'
    args = (), exc_info = None, func = 'get_or_create_from_git_repo'
    extra = {'author': 944, 'created': True, 'defaults': {'branch': 'main', 'name': 'test', 'private': True, 'service_id': 45}, 'name': 'test', ...}
    sinfo = None

    def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
    func=None, extra=None, sinfo=None):
    """
    A factory method which can be overridden in subclasses to create
    specialized LogRecords.
    """
    rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
    sinfo)
    if extra is not None:
    for key in extra:
    if (key in ["message", "asctime"]) or (key in rv.__dict__):
    > raise KeyError("Attempt to overwrite %r in LogRecord" % key)
    E KeyError: "Attempt to overwrite 'name' in LogRecord"

    .../local/lib/python3.12/logging/__init__.py:1656: KeyError
  • Class name: webhook_handlers.tests.test_github.GithubWebhookHandlerTests
    Test name: test_repo_creation_doesnt_crash_for_forked_repo

    self = <webhook_handlers.views.github.GithubWebhookHandler object at 0x7fb65b30c980>
    request = <rest_framework.request.Request: POST '/webhooks/github'>

    def _get_repo(self, request):
    """
    Attempts to fetch the repo first via the index on o(wnerid, service_id),
    then naively on service, service_id if that fails.
    """
    repo_data = self.request.data.get("repository", {})
    repo_service_id = repo_data.get("id")
    owner_service_id = repo_data.get("owner", {}).get("id")
    repo_slug = repo_data.get("full_name")

    try:
    owner = Owner.objects.get(
    service=self.service_name, service_id=owner_service_id
    )
    except Owner.DoesNotExist:
    log.info(
    f"Error fetching owner with service_id {owner_service_id}, "
    f"using repository service id to get repo",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    try:
    log.info(
    "Unable to find repository owner, fetching repo with service, service_id",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    return Repository.objects.get(
    author__service=self.service_name, service_id=repo_service_id
    )
    except Repository.DoesNotExist:
    log.info(
    "Received event for non-existent repository",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    raise NotFound("Repository does not exist")
    else:
    try:
    log.debug(
    "Found repository owner, fetching repo with ownerid, service_id",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    > return Repository.objects.get(
    author__ownerid=owner.ownerid, service_id=repo_service_id
    )

    webhook_handlers/views/github.py:145:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <RepositoryQuerySet []>, args = ()
    kwargs = {'author__ownerid': 2663, 'service_id': 506003}
    clone = <RepositoryQuerySet []>, limit = 21, num = 0

    def get(self, *args, **kwargs):
    """
    Perform the query and return a single object matching the given
    keyword arguments.
    """
    if self.query.combinator and (args or kwargs):
    raise NotSupportedError(
    "Calling QuerySet.get(...) with filters after %s() is not "
    "supported." % self.query.combinator
    )
    clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
    if self.query.can_filter() and not self.query.distinct_fields:
    clone = clone.order_by()
    limit = None
    if (
    not clone.query.select_for_update
    or connections[clone.db].features.supports_select_for_update_with_limit
    ):
    limit = MAX_GET_RESULTS
    clone.query.set_limits(high=limit)
    num = len(clone)
    if num == 1:
    return clone._result_cache[0]
    if not num:
    > raise self.model.DoesNotExist(
    "%s matching query does not exist." % self.model._meta.object_name
    )
    E shared.django_apps.core.models.Repository.DoesNotExist: Repository matching query does not exist.

    .../local/lib/python3.12.../db/models/query.py:637: DoesNotExist

    During handling of the above exception, another exception occurred:

    self = <webhook_handlers.tests.test_github.GithubWebhookHandlerTests testMethod=test_repo_creation_doesnt_crash_for_forked_repo>

    def test_repo_creation_doesnt_crash_for_forked_repo(self):
    owner = OwnerFactory(
    integration_id=4850403, service_id=97968493, service=Service.GITHUB.value
    )
    > self._post_event_data(
    event=GitHubWebhookEvents.REPOSITORY,
    data={
    "action": "publicized",
    "repository": {
    "id": 506003,
    "name": "testrepo",
    "private": False,
    "default_branch": "master",
    "owner": {"id": owner.service_id},
    "fork": True,
    "parent": {
    "name": "mainrepo",
    "language": "python",
    "id": 7940284,
    "private": False,
    "default_branch": "master",
    "owner": {"id": 8495712939, "login": "alogin"},
    },
    },
    },
    )

    webhook_handlers/tests/test_github.py:1421:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    webhook_handlers/tests/test_github.py:66: in _post_event_data
    return self.client.post(
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:295: in post
    response = super().post(
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:209: in post
    return self.generic('POST', path, data, content_type, **extra)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:233: in generic
    return super().generic(
    .../local/lib/python3.12.../django/test/client.py:609: in generic
    return self.request(**r)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:285: in request
    return super().request(**kwargs)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:237: in request
    request = super().request(**kwargs)
    .../local/lib/python3.12.../django/test/client.py:891: in request
    self.check_exception(response)
    .../local/lib/python3.12.../django/test/client.py:738: in check_exception
    raise exc_value
    .../local/lib/python3.12.../core/handlers/exception.py:55: in inner
    response = get_response(request)
    .../local/lib/python3.12.../core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
    .../local/lib/python3.12.../integrations/django/views.py:89: in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
    .../local/lib/python3.12.../views/decorators/csrf.py:56: in wrapper_view
    return view_func(*args, **kwargs)
    .../local/lib/python3.12.../views/generic/base.py:104: in view
    return self.dispatch(request, *args, **kwargs)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:509: in dispatch
    response = self.handle_exception(exc)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:469: in handle_exception
    self.raise_uncaught_exception(exc)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:480: in raise_uncaught_exception
    raise exc
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:506: in dispatch
    response = handler(request, *args, **kwargs)
    webhook_handlers/views/github.py:749: in post
    return handler(request, *args, **kwargs)
    webhook_handlers/views/github.py:170: in repository
    action, repo = self.request.data.get("action"), self._get_repo(request)
    webhook_handlers/views/github.py:156: in _get_repo
    return Repository.objects.get_or_create_from_git_repo(
    .../local/lib/python3.12.../django_apps/core/managers.py:402: in get_or_create_from_git_repo
    return self.get_queryset().get_or_create_from_git_repo(*args, **kwargs)
    .../local/lib/python3.12.../django_apps/core/managers.py:309: in get_or_create_from_git_repo
    log.info(
    .../local/lib/python3.12/logging/__init__.py:1539: in info
    self._log(INFO, msg, args, **kwargs)
    .../local/lib/python3.12/logging/__init__.py:1682: in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args,
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <Logger __name__ (INFO)>, name = '__name__', level = 20
    fn = '.../local/lib/python3.12.../django_apps/core/managers.py'
    lno = 309
    msg = '[GetOrCreateFromGitRepo] - Repo successfully updated or created'
    args = (), exc_info = None, func = 'get_or_create_from_git_repo'
    extra = {'author': 2663, 'created': True, 'defaults': {'branch': 'master', 'name': 'testrepo', 'private': False, 'service_id': 506003}, 'name': 'testrepo', ...}
    sinfo = None

    def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
    func=None, extra=None, sinfo=None):
    """
    A factory method which can be overridden in subclasses to create
    specialized LogRecords.
    """
    rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
    sinfo)
    if extra is not None:
    for key in extra:
    if (key in ["message", "asctime"]) or (key in rv.__dict__):
    > raise KeyError("Attempt to overwrite %r in LogRecord" % key)
    E KeyError: "Attempt to overwrite 'name' in LogRecord"

    .../local/lib/python3.12/logging/__init__.py:1656: KeyError
  • Class name: webhook_handlers.tests.test_github.GithubWebhookHandlerTests
    Test name: test_repo_not_found_when_owner_has_integration_creates_repo

    self = <webhook_handlers.views.github.GithubWebhookHandler object at 0x7fb65801c650>
    request = <rest_framework.request.Request: POST '/webhooks/github'>

    def _get_repo(self, request):
    """
    Attempts to fetch the repo first via the index on o(wnerid, service_id),
    then naively on service, service_id if that fails.
    """
    repo_data = self.request.data.get("repository", {})
    repo_service_id = repo_data.get("id")
    owner_service_id = repo_data.get("owner", {}).get("id")
    repo_slug = repo_data.get("full_name")

    try:
    owner = Owner.objects.get(
    service=self.service_name, service_id=owner_service_id
    )
    except Owner.DoesNotExist:
    log.info(
    f"Error fetching owner with service_id {owner_service_id}, "
    f"using repository service id to get repo",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    try:
    log.info(
    "Unable to find repository owner, fetching repo with service, service_id",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    return Repository.objects.get(
    author__service=self.service_name, service_id=repo_service_id
    )
    except Repository.DoesNotExist:
    log.info(
    "Received event for non-existent repository",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    raise NotFound("Repository does not exist")
    else:
    try:
    log.debug(
    "Found repository owner, fetching repo with ownerid, service_id",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    > return Repository.objects.get(
    author__ownerid=owner.ownerid, service_id=repo_service_id
    )

    webhook_handlers/views/github.py:145:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <RepositoryQuerySet []>, args = ()
    kwargs = {'author__ownerid': 2665, 'service_id': 506003}
    clone = <RepositoryQuerySet []>, limit = 21, num = 0

    def get(self, *args, **kwargs):
    """
    Perform the query and return a single object matching the given
    keyword arguments.
    """
    if self.query.combinator and (args or kwargs):
    raise NotSupportedError(
    "Calling QuerySet.get(...) with filters after %s() is not "
    "supported." % self.query.combinator
    )
    clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
    if self.query.can_filter() and not self.query.distinct_fields:
    clone = clone.order_by()
    limit = None
    if (
    not clone.query.select_for_update
    or connections[clone.db].features.supports_select_for_update_with_limit
    ):
    limit = MAX_GET_RESULTS
    clone.query.set_limits(high=limit)
    num = len(clone)
    if num == 1:
    return clone._result_cache[0]
    if not num:
    > raise self.model.DoesNotExist(
    "%s matching query does not exist." % self.model._meta.object_name
    )
    E shared.django_apps.core.models.Repository.DoesNotExist: Repository matching query does not exist.

    .../local/lib/python3.12.../db/models/query.py:637: DoesNotExist

    During handling of the above exception, another exception occurred:

    self = <webhook_handlers.tests.test_github.GithubWebhookHandlerTests testMethod=test_repo_not_found_when_owner_has_integration_creates_repo>

    def test_repo_not_found_when_owner_has_integration_creates_repo(self):
    owner = OwnerFactory(
    integration_id=4850403, service_id=97968493, service=Service.GITHUB.value
    )
    > self._post_event_data(
    event=GitHubWebhookEvents.REPOSITORY,
    data={
    "action": "publicized",
    "repository": {
    "id": 506003,
    "name": "testrepo",
    "private": False,
    "default_branch": "master",
    "owner": {"id": owner.service_id},
    },
    },
    )

    webhook_handlers/tests/test_github.py:1401:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    webhook_handlers/tests/test_github.py:66: in _post_event_data
    return self.client.post(
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:295: in post
    response = super().post(
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:209: in post
    return self.generic('POST', path, data, content_type, **extra)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:233: in generic
    return super().generic(
    .../local/lib/python3.12.../django/test/client.py:609: in generic
    return self.request(**r)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:285: in request
    return super().request(**kwargs)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:237: in request
    request = super().request(**kwargs)
    .../local/lib/python3.12.../django/test/client.py:891: in request
    self.check_exception(response)
    .../local/lib/python3.12.../django/test/client.py:738: in check_exception
    raise exc_value
    .../local/lib/python3.12.../core/handlers/exception.py:55: in inner
    response = get_response(request)
    .../local/lib/python3.12.../core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
    .../local/lib/python3.12.../integrations/django/views.py:89: in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
    .../local/lib/python3.12.../views/decorators/csrf.py:56: in wrapper_view
    return view_func(*args, **kwargs)
    .../local/lib/python3.12.../views/generic/base.py:104: in view
    return self.dispatch(request, *args, **kwargs)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:509: in dispatch
    response = self.handle_exception(exc)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:469: in handle_exception
    self.raise_uncaught_exception(exc)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:480: in raise_uncaught_exception
    raise exc
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:506: in dispatch
    response = handler(request, *args, **kwargs)
    webhook_handlers/views/github.py:749: in post
    return handler(request, *args, **kwargs)
    webhook_handlers/views/github.py:170: in repository
    action, repo = self.request.data.get("action"), self._get_repo(request)
    webhook_handlers/views/github.py:156: in _get_repo
    return Repository.objects.get_or_create_from_git_repo(
    .../local/lib/python3.12.../django_apps/core/managers.py:402: in get_or_create_from_git_repo
    return self.get_queryset().get_or_create_from_git_repo(*args, **kwargs)
    .../local/lib/python3.12.../django_apps/core/managers.py:309: in get_or_create_from_git_repo
    log.info(
    .../local/lib/python3.12/logging/__init__.py:1539: in info
    self._log(INFO, msg, args, **kwargs)
    .../local/lib/python3.12/logging/__init__.py:1682: in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args,
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <Logger __name__ (INFO)>, name = '__name__', level = 20
    fn = '.../local/lib/python3.12.../django_apps/core/managers.py'
    lno = 309
    msg = '[GetOrCreateFromGitRepo] - Repo successfully updated or created'
    args = (), exc_info = None, func = 'get_or_create_from_git_repo'
    extra = {'author': 2665, 'created': True, 'defaults': {'branch': 'master', 'name': 'testrepo', 'private': False, 'service_id': 506003}, 'name': 'testrepo', ...}
    sinfo = None

    def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
    func=None, extra=None, sinfo=None):
    """
    A factory method which can be overridden in subclasses to create
    specialized LogRecords.
    """
    rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
    sinfo)
    if extra is not None:
    for key in extra:
    if (key in ["message", "asctime"]) or (key in rv.__dict__):
    > raise KeyError("Attempt to overwrite %r in LogRecord" % key)
    E KeyError: "Attempt to overwrite 'name' in LogRecord"

    .../local/lib/python3.12/logging/__init__.py:1656: KeyError
  • Class name: webhook_handlers.tests.test_github_enterprise.GithubEnterpriseWebhookHandlerTests
    Test name: test_repo_creation_doesnt_crash_for_forked_repo

    self = <webhook_handlers.views.github.GithubEnterpriseWebhookHandler object at 0x7fb65888ccb0>
    request = <rest_framework.request.Request: POST '/webhooks/github_enterprise'>

    def _get_repo(self, request):
    """
    Attempts to fetch the repo first via the index on o(wnerid, service_id),
    then naively on service, service_id if that fails.
    """
    repo_data = self.request.data.get("repository", {})
    repo_service_id = repo_data.get("id")
    owner_service_id = repo_data.get("owner", {}).get("id")
    repo_slug = repo_data.get("full_name")

    try:
    owner = Owner.objects.get(
    service=self.service_name, service_id=owner_service_id
    )
    except Owner.DoesNotExist:
    log.info(
    f"Error fetching owner with service_id {owner_service_id}, "
    f"using repository service id to get repo",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    try:
    log.info(
    "Unable to find repository owner, fetching repo with service, service_id",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    return Repository.objects.get(
    author__service=self.service_name, service_id=repo_service_id
    )
    except Repository.DoesNotExist:
    log.info(
    "Received event for non-existent repository",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    raise NotFound("Repository does not exist")
    else:
    try:
    log.debug(
    "Found repository owner, fetching repo with ownerid, service_id",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    > return Repository.objects.get(
    author__ownerid=owner.ownerid, service_id=repo_service_id
    )

    webhook_handlers/views/github.py:145:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <RepositoryQuerySet []>, args = ()
    kwargs = {'author__ownerid': 2745, 'service_id': 506003}
    clone = <RepositoryQuerySet []>, limit = 21, num = 0

    def get(self, *args, **kwargs):
    """
    Perform the query and return a single object matching the given
    keyword arguments.
    """
    if self.query.combinator and (args or kwargs):
    raise NotSupportedError(
    "Calling QuerySet.get(...) with filters after %s() is not "
    "supported." % self.query.combinator
    )
    clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
    if self.query.can_filter() and not self.query.distinct_fields:
    clone = clone.order_by()
    limit = None
    if (
    not clone.query.select_for_update
    or connections[clone.db].features.supports_select_for_update_with_limit
    ):
    limit = MAX_GET_RESULTS
    clone.query.set_limits(high=limit)
    num = len(clone)
    if num == 1:
    return clone._result_cache[0]
    if not num:
    > raise self.model.DoesNotExist(
    "%s matching query does not exist." % self.model._meta.object_name
    )
    E shared.django_apps.core.models.Repository.DoesNotExist: Repository matching query does not exist.

    .../local/lib/python3.12.../db/models/query.py:637: DoesNotExist

    During handling of the above exception, another exception occurred:

    self = <webhook_handlers.tests.test_github_enterprise.GithubEnterpriseWebhookHandlerTests testMethod=test_repo_creation_doesnt_crash_for_forked_repo>

    def test_repo_creation_doesnt_crash_for_forked_repo(self):
    owner = OwnerFactory(
    integration_id=4850403,
    service_id=97968493,
    service=Service.GITHUB_ENTERPRISE.value,
    )
    > self._post_event_data(
    event=GitHubWebhookEvents.REPOSITORY,
    data={
    "action": "publicized",
    "repository": {
    "id": 506003,
    "name": "testrepo",
    "private": False,
    "default_branch": "master",
    "owner": {"id": owner.service_id},
    "fork": True,
    "parent": {
    "name": "mainrepo",
    "language": "python",
    "id": 7940284,
    "private": False,
    "default_branch": "master",
    "owner": {"id": 8495712939, "login": "alogin"},
    },
    },
    },
    )

    webhook_handlers/tests/test_github_enterprise.py:1162:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    webhook_handlers/tests/test_github_enterprise.py:48: in _post_event_data
    return self.client.post(
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:295: in post
    response = super().post(
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:209: in post
    return self.generic('POST', path, data, content_type, **extra)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:233: in generic
    return super().generic(
    .../local/lib/python3.12.../django/test/client.py:609: in generic
    return self.request(**r)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:285: in request
    return super().request(**kwargs)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:237: in request
    request = super().request(**kwargs)
    .../local/lib/python3.12.../django/test/client.py:891: in request
    self.check_exception(response)
    .../local/lib/python3.12.../django/test/client.py:738: in check_exception
    raise exc_value
    .../local/lib/python3.12.../core/handlers/exception.py:55: in inner
    response = get_response(request)
    .../local/lib/python3.12.../core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
    .../local/lib/python3.12.../integrations/django/views.py:89: in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
    .../local/lib/python3.12.../views/decorators/csrf.py:56: in wrapper_view
    return view_func(*args, **kwargs)
    .../local/lib/python3.12.../views/generic/base.py:104: in view
    return self.dispatch(request, *args, **kwargs)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:509: in dispatch
    response = self.handle_exception(exc)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:469: in handle_exception
    self.raise_uncaught_exception(exc)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:480: in raise_uncaught_exception
    raise exc
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:506: in dispatch
    response = handler(request, *args, **kwargs)
    webhook_handlers/views/github.py:749: in post
    return handler(request, *args, **kwargs)
    webhook_handlers/views/github.py:170: in repository
    action, repo = self.request.data.get("action"), self._get_repo(request)
    webhook_handlers/views/github.py:156: in _get_repo
    return Repository.objects.get_or_create_from_git_repo(
    .../local/lib/python3.12.../django_apps/core/managers.py:402: in get_or_create_from_git_repo
    return self.get_queryset().get_or_create_from_git_repo(*args, **kwargs)
    .../local/lib/python3.12.../django_apps/core/managers.py:309: in get_or_create_from_git_repo
    log.info(
    .../local/lib/python3.12/logging/__init__.py:1539: in info
    self._log(INFO, msg, args, **kwargs)
    .../local/lib/python3.12/logging/__init__.py:1682: in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args,
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <Logger __name__ (INFO)>, name = '__name__', level = 20
    fn = '.../local/lib/python3.12.../django_apps/core/managers.py'
    lno = 309
    msg = '[GetOrCreateFromGitRepo] - Repo successfully updated or created'
    args = (), exc_info = None, func = 'get_or_create_from_git_repo'
    extra = {'author': 2745, 'created': True, 'defaults': {'branch': 'master', 'name': 'testrepo', 'private': False, 'service_id': 506003}, 'name': 'testrepo', ...}
    sinfo = None

    def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
    func=None, extra=None, sinfo=None):
    """
    A factory method which can be overridden in subclasses to create
    specialized LogRecords.
    """
    rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
    sinfo)
    if extra is not None:
    for key in extra:
    if (key in ["message", "asctime"]) or (key in rv.__dict__):
    > raise KeyError("Attempt to overwrite %r in LogRecord" % key)
    E KeyError: "Attempt to overwrite 'name' in LogRecord"

    .../local/lib/python3.12/logging/__init__.py:1656: KeyError
  • Class name: webhook_handlers.tests.test_github_enterprise.GithubEnterpriseWebhookHandlerTests
    Test name: test_repo_not_found_when_owner_has_integration_creates_repo

    self = <webhook_handlers.views.github.GithubEnterpriseWebhookHandler object at 0x7fb658165d60>
    request = <rest_framework.request.Request: POST '/webhooks/github_enterprise'>

    def _get_repo(self, request):
    """
    Attempts to fetch the repo first via the index on o(wnerid, service_id),
    then naively on service, service_id if that fails.
    """
    repo_data = self.request.data.get("repository", {})
    repo_service_id = repo_data.get("id")
    owner_service_id = repo_data.get("owner", {}).get("id")
    repo_slug = repo_data.get("full_name")

    try:
    owner = Owner.objects.get(
    service=self.service_name, service_id=owner_service_id
    )
    except Owner.DoesNotExist:
    log.info(
    f"Error fetching owner with service_id {owner_service_id}, "
    f"using repository service id to get repo",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    try:
    log.info(
    "Unable to find repository owner, fetching repo with service, service_id",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    return Repository.objects.get(
    author__service=self.service_name, service_id=repo_service_id
    )
    except Repository.DoesNotExist:
    log.info(
    "Received event for non-existent repository",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    raise NotFound("Repository does not exist")
    else:
    try:
    log.debug(
    "Found repository owner, fetching repo with ownerid, service_id",
    extra=dict(repo_service_id=repo_service_id, repo_slug=repo_slug),
    )
    > return Repository.objects.get(
    author__ownerid=owner.ownerid, service_id=repo_service_id
    )

    webhook_handlers/views/github.py:145:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12.../db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <RepositoryQuerySet []>, args = ()
    kwargs = {'author__ownerid': 2747, 'service_id': 506003}
    clone = <RepositoryQuerySet []>, limit = 21, num = 0

    def get(self, *args, **kwargs):
    """
    Perform the query and return a single object matching the given
    keyword arguments.
    """
    if self.query.combinator and (args or kwargs):
    raise NotSupportedError(
    "Calling QuerySet.get(...) with filters after %s() is not "
    "supported." % self.query.combinator
    )
    clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
    if self.query.can_filter() and not self.query.distinct_fields:
    clone = clone.order_by()
    limit = None
    if (
    not clone.query.select_for_update
    or connections[clone.db].features.supports_select_for_update_with_limit
    ):
    limit = MAX_GET_RESULTS
    clone.query.set_limits(high=limit)
    num = len(clone)
    if num == 1:
    return clone._result_cache[0]
    if not num:
    > raise self.model.DoesNotExist(
    "%s matching query does not exist." % self.model._meta.object_name
    )
    E shared.django_apps.core.models.Repository.DoesNotExist: Repository matching query does not exist.

    .../local/lib/python3.12.../db/models/query.py:637: DoesNotExist

    During handling of the above exception, another exception occurred:

    self = <webhook_handlers.tests.test_github_enterprise.GithubEnterpriseWebhookHandlerTests testMethod=test_repo_not_found_when_owner_has_integration_creates_repo>

    def test_repo_not_found_when_owner_has_integration_creates_repo(self):
    owner = OwnerFactory(
    integration_id=4850403,
    service_id=97968493,
    service=Service.GITHUB_ENTERPRISE.value,
    )
    > self._post_event_data(
    event=GitHubWebhookEvents.REPOSITORY,
    data={
    "action": "publicized",
    "repository": {
    "id": 506003,
    "name": "testrepo",
    "private": False,
    "default_branch": "master",
    "owner": {"id": owner.service_id},
    },
    },
    )

    webhook_handlers/tests/test_github_enterprise.py:1140:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    webhook_handlers/tests/test_github_enterprise.py:48: in _post_event_data
    return self.client.post(
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:295: in post
    response = super().post(
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:209: in post
    return self.generic('POST', path, data, content_type, **extra)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:233: in generic
    return super().generic(
    .../local/lib/python3.12.../django/test/client.py:609: in generic
    return self.request(**r)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:285: in request
    return super().request(**kwargs)
    .../local/lib/python3.12.............../site-packages/rest_framework/test.py:237: in request
    request = super().request(**kwargs)
    .../local/lib/python3.12.../django/test/client.py:891: in request
    self.check_exception(response)
    .../local/lib/python3.12.../django/test/client.py:738: in check_exception
    raise exc_value
    .../local/lib/python3.12.../core/handlers/exception.py:55: in inner
    response = get_response(request)
    .../local/lib/python3.12.../core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
    .../local/lib/python3.12.../integrations/django/views.py:89: in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
    .../local/lib/python3.12.../views/decorators/csrf.py:56: in wrapper_view
    return view_func(*args, **kwargs)
    .../local/lib/python3.12.../views/generic/base.py:104: in view
    return self.dispatch(request, *args, **kwargs)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:509: in dispatch
    response = self.handle_exception(exc)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:469: in handle_exception
    self.raise_uncaught_exception(exc)
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:480: in raise_uncaught_exception
    raise exc
    .../local/lib/python3.12............/site-packages/rest_framework/views.py:506: in dispatch
    response = handler(request, *args, **kwargs)
    webhook_handlers/views/github.py:749: in post
    return handler(request, *args, **kwargs)
    webhook_handlers/views/github.py:170: in repository
    action, repo = self.request.data.get("action"), self._get_repo(request)
    webhook_handlers/views/github.py:156: in _get_repo
    return Repository.objects.get_or_create_from_git_repo(
    .../local/lib/python3.12.../django_apps/core/managers.py:402: in get_or_create_from_git_repo
    return self.get_queryset().get_or_create_from_git_repo(*args, **kwargs)
    .../local/lib/python3.12.../django_apps/core/managers.py:309: in get_or_create_from_git_repo
    log.info(
    .../local/lib/python3.12/logging/__init__.py:1539: in info
    self._log(INFO, msg, args, **kwargs)
    .../local/lib/python3.12/logging/__init__.py:1682: in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args,
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <Logger __name__ (INFO)>, name = '__name__', level = 20
    fn = '.../local/lib/python3.12.../django_apps/core/managers.py'
    lno = 309
    msg = '[GetOrCreateFromGitRepo] - Repo successfully updated or created'
    args = (), exc_info = None, func = 'get_or_create_from_git_repo'
    extra = {'author': 2747, 'created': True, 'defaults': {'branch': 'master', 'name': 'testrepo', 'private': False, 'service_id': 506003}, 'name': 'testrepo', ...}
    sinfo = None

    def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
    func=None, extra=None, sinfo=None):
    """
    A factory method which can be overridden in subclasses to create
    specialized LogRecords.
    """
    rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
    sinfo)
    if extra is not None:
    for key in extra:
    if (key in ["message", "asctime"]) or (key in rv.__dict__):
    > raise KeyError("Attempt to overwrite %r in LogRecord" % key)
    E KeyError: "Attempt to overwrite 'name' in LogRecord"

    .../local/lib/python3.12/logging/__init__.py:1656: KeyError

@jason-ford-codecov jason-ford-codecov added this pull request to the merge queue Oct 1, 2024
Merged via the queue into main with commit c24ddc5 Oct 1, 2024
19 checks passed
@jason-ford-codecov jason-ford-codecov deleted the release/24.10.1 branch October 1, 2024 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants