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(appstore-connect): Add a new endpoint that returns the status of all configured apps [NATIVE-294] #29728

Merged
merged 15 commits into from
Nov 9, 2021

Conversation

relaxolotl
Copy link
Contributor

@relaxolotl relaxolotl commented Nov 3, 2021

@ potential reviewers: i would really recommend reviewing this commit-by-commit, or to at least review the code without 3116b92 included as it performs a rename that only clutters the diff

This creates a new endpoint appstoreconnect/status meant to replace appstoreconnect/validate/{id}/.

This new endpoint does the following things differently from its predecessor:

  • Returns more detailed diagnostics if API keys are invalid
  • Returns statuses of all apps(/sources) configured for a project if multiple apps(/sources) are found for the project

The following frontend changes have been made in response:

  • Parses the aforementioned more detailed diagnostics and shows more specific messages accordingly during update
  • Handles lists of statuses being returned properly
  • Since since the detailed diagnostics are going to be reused when validating the API keys when creating a new app(/source), some preliminary work has been done to use the same code to handle those diagnostics responses for both the /validate and the /apps endpoints.

Screenshots

When submitting invalid credentials (changed from "An unexpected error occurred while configuring...")

Screenshot 2021-11-04 at 12 13 46 AM

Inline warning

Screenshot 2021-11-04 at 12 11 22 AM

Context shown after clicking on inline warning

Screenshot 2021-11-04 at 1 12 38 AM

Screenshot 2021-11-04 at 1 13 18 AM

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2021

size-limit report

Path Base Size (61ccbff) Current Size Change
src/sentry/static/sentry/dist/entrypoints/app.js 52.77 KB 52.8 KB +0.06% 🔺
src/sentry/static/sentry/dist/entrypoints/sentry.css 70.89 KB 70.89 KB 0%

@relaxolotl
Copy link
Contributor Author

i need to get a few test api keys set up to see what apple returns in a few easy-to-reproduce situations.

except appstore_connect.UnauthorizedError:
asc_credentials = {
"status": "invalid",
"code": AppConnectAuthenticationError().code,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to throw these errors directly in /app so the FE can use the same code to handle the validation messages returned by this endpoint as well as /status

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure you need to instantiate the class here, can you not access the code attribute without instantiating?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right about that, thanks for catching this!

@relaxolotl relaxolotl marked this pull request as ready for review November 4, 2021 06:17
@relaxolotl relaxolotl requested a review from a team as a code owner November 4, 2021 06:17
@relaxolotl relaxolotl requested review from a team and priscilawebdev November 4, 2021 06:17
@@ -1,3 +1,5 @@
import {ValidationErrorDetailed} from 'app/components/modals/debugFileCustomRepository/appStoreConnect/utils';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't introduce a circular import but i'm not particularly confident about this import. maybe it's better to just duplicate the type here instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move the ValidationErrorDetailed type and maybe add some AppStoreConnect prefix or rename it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have any ideas on where ValidationErrorDetailed could be moved to? i'm not too familiar with the front end's file structure so hints here would be very helpful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not worry... I worked on this in the PR #29843

@relaxolotl
Copy link
Contributor Author

relaxolotl commented Nov 4, 2021

@ potential reviewers: i would really recommend reviewing this commit-by-commit, or to at least review the code without 3116b92 included as it performs a rename that only clutters the diff

Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice!

(but there are no tests :( )

```json
{
"appstoreCredentialsValid": true,
"pendingDownloads": 123,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we're just hiding the fact that pendingDownloads can be undefined right after a new source is created. The implementation here queries the database and will return 0 pending downloads if we never ran the task. This could be a tiny bit odd if our workers are a bit slow. But probably not important enough to worry about so I don't mind if we keep it like this.

Copy link
Contributor Author

@relaxolotl relaxolotl Nov 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, i've got something written down right now to investigate this as i've been seeing this behaviour after the switch to using the app store connect API to download dSYMs. i'm currently unsure what the best solution for this would be as it would probably need coordination from the front end, but i'm thinking we can maybe defer the work to address this to later on in the quarter unless we're getting a lot of customer feedback on this.

except appstore_connect.UnauthorizedError:
asc_credentials = {
"status": "invalid",
"code": AppConnectAuthenticationError().code,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure you need to instantiate the class here, can you not access the code attribute without instantiating?

@relaxolotl
Copy link
Contributor Author

fyi @priscilawebdev @flub i've rebased this off of master to resolve the conflicts and to prune some duplicate commits due to a recent merge of a dependency. i moved the rename commit back to the bottom of the commit stack to make it easier to omit it from the diff during review.

@relaxolotl
Copy link
Contributor Author

status endpoint is currently throwing 405s for some reason, will investigate later after lunch

@relaxolotl
Copy link
Contributor Author

@priscilawebdev i believe i've addressed all of your feedback, so this should be good for a second look. if you're unable to find time to take a second look by tomorrow, i'll merge this in first and let's follow up on any remaining feedback you've got in another PR.

Copy link
Member

@priscilawebdev priscilawebdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@@ -1,3 +1,5 @@
import {ValidationErrorDetailed} from 'app/components/modals/debugFileCustomRepository/appStoreConnect/utils';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not worry... I worked on this in the PR #29843

switch (error.code) {
case 'app-connect-authentication-error':
return t(
'Credentials are invalid or missing. Check the entered App Store Connect credentials are correct.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

@relaxolotl relaxolotl merged commit bcfd90a into master Nov 9, 2021
@relaxolotl relaxolotl deleted the appconnect/extended-validate branch November 9, 2021 15:17
@relaxolotl relaxolotl changed the title fix(appstore-connect): Add a new endpoint that returns the status of all configured apps fix(appstore-connect): Add a new endpoint that returns the status of all configured apps [NATIVE-294] Nov 9, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants