-
Notifications
You must be signed in to change notification settings - Fork 141
fix: mongoDB client impl issues #1167
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
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1167 +/- ##
==========================================
+ Coverage 82.70% 82.76% +0.06%
==========================================
Files 66 66
Lines 2781 2780 -1
Branches 333 332 -1
==========================================
+ Hits 2300 2301 +1
+ Misses 432 431 -1
+ Partials 49 48 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Looks good, although you missed an await on the find in getUsers
@andypols thanks, fixed. Had a brief poke at why TypeScript isn't helping catch these, a tweak to the |
@finos/git-proxy-maintainers this is ready for review and merge - happy to try and get that next RC out (perhaps tomorrow) when it and one other PR are in. |
@kriswest I'll do some manual testing with a MongoDB setup for this one first thing tomorrow. Just want to make sure nothing is missing 🙂 |
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.
Tested most of the flows with MongoDB Atlas:
- Creating new repo
- Fetching all repos
- Logging in through OIDC (user creation)
- Adding user to push/approval list
- Pushing to repo
- Fetching all pushes
- Approving a push
Everything seems to be working fine! 🎉
I did find a minor issue on the pushes table:
<TableCell>
{isGitHub && (
<a
href={`https://github.com/${c.committer}`}
rel='noreferrer'
target='_blank'
>
{c.committer}
</a>
)}
{!isGitHub && <span>{c.committer}</span>}
</TableCell>

The committer
is Juan Escalada
with a space in the middle which makes the a
tag rendering fail. This might be due an issue with the OIDC implementation, but I think that commitData.committer
is set to be the Git user.name
rather than the GitHub username.
Any thoughts on this?
@jescalada thats interesting - that's an existing flaw based on the assumption that the committer name would be set to the GitHub id, which is not the case in Github's own getting started instructions: https://docs.github.com/en/get-started/git-basics/setting-your-username-in-git#setting-your-git-username-for-every-repository-on-your-computer Looking around, its not easy to get the GitHub id from the email address - at best you can search against the single, optional public/primary email address with the API. E.g. This works: https://api.github.com/search/[email protected] but this doesn't https://api.github.com/search/[email protected] This lib offers an alternative based on searching for commits with the email address: https://github.com/sindresorhus/github-username Alternatively, we just drop that link and instead render the email address, with a mailto: link? That might actually be more useful that the github profile link! WDYT? |
@kriswest I lean towards whatever is easiest to implement and won't cause issues down the line due to edge cases 😃 The GitHub username is nice to have, I just don't understand why this isn't being recorded/extracted correctly in GitProxy (we still have that confusing "gitAccount" variable and endpoint which could be clarified). By the way, I tested with the regular account and still get that "Juan Escalada" name issue, so it doesn't seem like GitProxy is trying to resolve the GH username to begin with. Maybe plugging it into the |
There are two places with this issue I think, ui/views/OpenpushRequests/components/PushesTable.tsx and ui/views/PushDetails/PushDetails.tsx. These should be using the same util function to render, but are not. Both are assuming the committer is set the the username at that platform - although only one of them supports that for Gitlab. In neither case is it a safe assumption. There is no attempt to resolve to the username through the gitAccount fields from our users tables (which can only support one user name and doesn't link it to a platform...). I think changing this up to render the name and a link for the email address is the easiest and safest thing to do - the email address is really the only thing we can rely on. We can then work from there to reintroduce a way of resolving the user to either a github or gitlab user profile, with handling for failures to resolve. The resolution could either be through an API lookup of some sort (if a reliable one can be found) OR resolution through out own user table, after updating it to support usernames for multiple SCM providers. I'll raise two issues covering that and will have a quick crack to the first (to fix the immediate rendering issues and give us email links). Let em know if you'd prefer we went another way. |
Sounds good to me! Feel free to merge this one in. This should be enough to make the |
@andypols noted a couple of implementation errors in the mongoDB client (not awaiting promises, searching for repos against the wrong field), which this PR corrects.
The error is not picked up by tests as our testing of the mongo client is inadequate. I'll open a separate issue to resolve that. In the meantime, this PR will need to be tested manually.