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

reactivate ghapp usage in api #360

Merged
merged 6 commits into from
Jan 30, 2024
Merged

reactivate ghapp usage in api #360

merged 6 commits into from
Jan 30, 2024

Conversation

giovanni-guidini
Copy link
Contributor

reactivate ghapp usage in api and fix bug when getting file contents.

This bug caused a little incident in Codecov.

The actual issue is that we can't make DB queries syncronously from an
async context.

When getting the file content we have to get an adapter,
and that - since the GithubAppInstallation work - required a query to
the database to get the default GithubAppInstallation for an owner.
That was the actual error that caused the incident.

Error surfacing was terrible in that endpoint so I changed the info log
from an exception one so we can have a stacktrace.

To actually fix the error I actually created an async version of get_adapter.
I scanned the code, but it seems that this instance is the only place where we
actually use this.

Purpose/Motivation

What is the feature? Why is this being done?

Links to relevant tickets

What does this PR do?

Include a brief description of the changes in this PR. Bullet points are your friend.

Notes to Reviewer

Anything to note to the team? Any tips on how to review, or where to start?

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.

This bug caused a little incident in Codecov.

The actual issue is that we can't make DB queries syncronously from an
async context.

When getting the file content we have to get an adapter,
and that - since the GithubAppInstallation work - required a query to
the database to get the default GithubAppInstallation for an `owner`.
That was the actual error that caused the incident.

Error surfacing was terrible in that endpoint so I changed the `info` log
from an `exception` one so we can have a stacktrace.

To actually fix the error I actually created an async version of `get_adapter`.
I scanned the code, but it seems that this instance is the only place where we
actually use this.
Tests for the interactor (which is async) are now marked as `async`.

I believe that marking them with `@async_to_sync` instead of `pytest.mark.async`
may have hidden the bug that we faced about running the DB query in the async context.
Not tested this theory tho.
@codecov-staging
Copy link

codecov-staging bot commented Jan 26, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Files Patch % Lines
utils/github.py 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

codecov-public-qa bot commented Jan 26, 2024

Codecov Report

Merging #360 (9c43770) into main (2e76d3b) will increase coverage by 0.00%.
The diff coverage is 98.70%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #360   +/-   ##
=======================================
  Coverage   96.08%   96.08%           
=======================================
  Files         632      632           
  Lines       16409    16470   +61     
=======================================
+ Hits        15766    15826   +60     
- Misses        643      644    +1     
Flag Coverage Δ
unit 96.08% <98.70%> (+<0.01%) ⬆️
unit-latest-uploader 96.08% <98.70%> (+<0.01%) ⬆️

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

Files Coverage Δ
...re/commands/commit/interactors/get_file_content.py 100.00% <100.00%> (ø)
services/repo_providers.py 97.05% <100.00%> (-0.86%) ⬇️
upload/helpers.py 94.25% <100.00%> (+0.22%) ⬆️
webhook_handlers/views/github.py 98.99% <100.00%> (+0.11%) ⬆️
utils/github.py 80.00% <50.00%> (ø)

Impacted file tree graph

Copy link

codecov bot commented Jan 26, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (2e76d3b) 95.75% compared to head (a65be68) 95.77%.

❗ Current head a65be68 differs from pull request most recent head 9c43770. Consider uploading reports for the commit 9c43770 to get more accurate results

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

Files Patch % Lines
utils/github.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #360     +/-   ##
=======================================
+ Coverage   95.75   95.77   +0.02     
=======================================
  Files        747     747             
  Lines      16927   16987     +60     
=======================================
+ Hits       16208   16268     +60     
  Misses       719     719             
Flag Coverage Δ
unit 96.08% <98.70%> (+<0.01%) ⬆️
unit-latest-uploader 96.08% <98.70%> (+<0.01%) ⬆️

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.

@codecov-qa
Copy link

codecov-qa bot commented Jan 26, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (2e76d3b) 96.08% compared to head (9c43770) 96.08%.

Files Patch % Lines
utils/github.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #360   +/-   ##
=======================================
  Coverage   96.08%   96.08%           
=======================================
  Files         632      632           
  Lines       16409    16470   +61     
=======================================
+ Hits        15766    15826   +60     
- Misses        643      644    +1     
Flag Coverage Δ
unit 96.08% <98.70%> (+<0.01%) ⬆️
unit-latest-uploader 96.08% <98.70%> (+<0.01%) ⬆️

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.

@giovanni-guidini giovanni-guidini merged commit 0d51fa4 into main Jan 30, 2024
16 of 17 checks passed
@giovanni-guidini giovanni-guidini deleted the gio/multi-apps/usage branch January 30, 2024 17:03
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.

None yet

3 participants