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

[fix] Fix duplicate key value violates unique constraint "owner_service_ids" Sentry errors #705

Merged
merged 7 commits into from
Jul 24, 2024

Conversation

rohitvinnakota-codecov
Copy link
Contributor

Purpose/Motivation

This PR closes https://github.com/codecov/internal-issues/issues/493

We query for an owner during webhook events using get_or_create based on their service, service_id, and username. The combination of service and service_id serves as a unique key. We have cases where we have entries in the users table with no username so the get part of the get_or_create would return None and the create part attempts to create a new entry but fails due to violating the constraint. This change moves the username field to be a default argument.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Copy link

sentry-io bot commented Jul 23, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: webhook_handlers/views/github.py

Function Unhandled Issue
_handle_installation_repository_events GithubAppInstallation.MultipleObjectsReturned: get() returned more than one GithubAppInstallation -- it returned 2! ...
Event Count: 22

Did you find this useful? React with a 👍 or 👎

@codecov-qa
Copy link

codecov-qa bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.65%. Comparing base (8339939) to head (25e5b3a).

✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main     #705   +/-   ##
=======================================
  Coverage   91.65%   91.65%           
=======================================
  Files         632      632           
  Lines       16917    16917           
=======================================
  Hits        15506    15506           
  Misses       1411     1411           
Flag Coverage Δ
unit 91.65% <ø> (ø)
unit-latest-uploader 91.65% <ø> (ø)

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

Files Coverage Δ
webhook_handlers/views/github.py 99.06% <ø> (ø)

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@codecov-notifications
Copy link

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-public-qa bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.65%. Comparing base (8339939) to head (25e5b3a).

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #705   +/-   ##
=======================================
  Coverage   91.65%   91.65%           
=======================================
  Files         632      632           
  Lines       16917    16917           
=======================================
  Hits        15506    15506           
  Misses       1411     1411           
Flag Coverage Δ
unit 91.65% <ø> (ø)
unit-latest-uploader 91.65% <ø> (ø)

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

Files Coverage Δ
webhook_handlers/views/github.py 99.06% <ø> (ø)

Impacted file tree graph

Copy link

codecov bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.98%. Comparing base (8339939) to head (25e5b3a).

Changes have been made to critical files, which contain lines commonly executed in production. Learn more

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##               main       #705   +/-   ##
===========================================
  Coverage   95.98000   95.98000           
===========================================
  Files           812        812           
  Lines         18254      18254           
===========================================
  Hits          17522      17522           
  Misses          732        732           
Flag Coverage Δ
unit 91.65% <ø> (ø)
unit-latest-uploader 91.65% <ø> (ø)

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.

@rohitvinnakota-codecov rohitvinnakota-codecov marked this pull request as ready for review July 23, 2024 18:00
@rohitvinnakota-codecov rohitvinnakota-codecov added this pull request to the merge queue Jul 24, 2024
Merged via the queue into main with commit 8029a94 Jul 24, 2024
21 of 22 checks passed
@rohitvinnakota-codecov rohitvinnakota-codecov deleted the rvinnakota/update-get-or-create-owner branch July 24, 2024 14:17
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.

2 participants