- 
                Notifications
    You must be signed in to change notification settings 
- Fork 10
Add a new GraphQL mutation to sync with app token #202
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
Conversation
| Sentry detected 3 potential issues in your recent changesThere's a suspicion that the new syncRepos mutation might encounter an AttributeError if current_owner is None due to bypassed validation, potentially causing unexpected behavior.
 It's suspected that the SyncReposTask, when triggered by the new syncRepos mutation, lacks error handling for NoConfiguredAppsAvailable or InvalidInstallationError from GitHub App token retrieval, potentially leading to Celery task crashes.
 It is suspected that if current_owner.user is None, accessing self.current_user.is_authenticated in BaseInteractor will cause an AttributeError. This risk is heightened by the new mutation.
 Did you find this useful? React with a 👍 or 👎 | 
| Codecov ReportAll modified and coverable lines are covered by tests ✅ 
 ✅ All tests successful. No failed tests found. Additional details and impacted files@@           Coverage Diff           @@
##             main     #202   +/-   ##
=======================================
  Coverage   94.31%   94.31%           
=======================================
  Files        1230     1232    +2     
  Lines       45306    45325   +19     
  Branches     1449     1449           
=======================================
+ Hits        42732    42750   +18     
- Misses       2270     2271    +1     
  Partials      304      304           
 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. | 
| Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. 📢 Thoughts on this report? Let us know! | 
ac55e54    to
    ff57c37      
    Compare
  
    | mutation = ariadne_load_local_graphql(__file__, "mutation.graphql") | ||
| mutation = mutation + gql_create_api_token | ||
| mutation = mutation + gql_create_stripe_setup_intent | ||
| mutation = mutation + gql_sync_repos | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on a comment here to let folks know these are both triggering the sync task, one is just using integration and the other isn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment to sync_repos.py
        
          
                apps/codecov-api/graphql_api/types/mutation/sync_repos/sync_repos.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
      ff57c37    to
    9f2cbaf      
    Compare
  
    This change makes the sync task use an app token rather than the user's token. It's a separate mutation, so it shouldn't conflict with the existing sync trigger.
9f2cbaf    to
    f69ae13      
    Compare
  
    | union SyncReposError = UnauthenticatedError | ||
|  | ||
| type SyncReposPayload { | ||
| isSyncing: Boolean | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this should be required right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with an "!" I mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it doesn't work with errors. I'll need to have that be nullable in case there is an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhh gotcha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we either return isSyncing or the error in the payload
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, one small comment
This change makes the sync task use an app token rather than the user's token. It's a separate mutation, so it shouldn't conflict with the existing sync trigger.
Just also note that the
current_owneris set to be the org with the JWT middleware:umbrella/apps/codecov-api/codecov_auth/middleware.py
Line 200 in 3541fda