Repository navigation
make loadAndCacheUser more resilient to bad input - #6945
Merged
Merged
Conversation
shiftkey
force-pushed
the
review-users-from-api
branch
from
February 26, 2019 14:26
299a24a to
9d0a484
Compare
shiftkey
marked this pull request as ready for review
February 26, 2019 18:06
iAmWillShepherd
approved these changes
Mar 8, 2019
| * Minimum subset of an identity returned by the GitHub API | ||
| */ | ||
| export interface IAPIIdentity { | ||
| readonly id: number |
Contributor
There was a problem hiding this comment.
Non-blocking
Is it possible to use a sum/intersection type here to take advantage of the fact that these same fields are defined in the type above?
Member
Author
There was a problem hiding this comment.
I didn't really see the value in coupling these together to save on typings because it felt like a different version of our mistake of assuming IAPIUser everywhere. Also, using IAPIOrganization (a special case returned by a specific API) to derive IAPIIdentity (a more general case used broadly in the API) doesn't make sense to me from a composition side.
This comment has been minimized.
This comment has been minimized.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Related to #6313
Description
This PR addresses a few things I uncovered during the investigation for #6313. I couldn't reproduce the "menus disabled" behaviour but I could trigger everything else.
Here's what I found:
authorfor some commits, instead ofnullThis was fixed in 2484ff6 to add a runtime check that the object found is the expected shape and contents.
IAPIUserto represent a unified account does not reflect what was returned by the API. I uncovered three different shapes of data,IAPIUserhas been deprecated in favour of these three shapes in 8847ef6:IAPIFullIdentity- this is the same shape asIAPIUserbut is only used in two places -/user( the details about the current user) and/users/{user}to find details about a GitHub accountIAPIIdentity- this is the subset of account information that is used in most places of the API - commits, pull requests, etc. Nonameoremailis provided in this payload, irrespective of the privacy settings defined by the user. I didn't notice any strange issues downstream as a result of this change, but this is something to be mindful of while I'm doing more testing.IAPIOrganization- the array of objects returned by/user/orgsis similar toIAPIIdentity, but for some reason omitted thetypevalue (because only organizations are returned by this endpoint?).""in GitWe have a few places where we look for a
nullemail and bail out, so I also added checks for""in 9d0a484 to save API calls when searching for a user.Release notes
Notes:
[Fixed] caching GitHub users does not handle edge case where email is empty string