lumen-notes / lumen

A simple note-taking app for capturing and organizing your thoughts
https://app.uselumen.com
MIT License
438 stars 28 forks source link

GitPushError: push declined due to email privacy restrictions #436

Open UshiHiraga opened 23 hours ago

UshiHiraga commented 23 hours ago

Sync fails. In developer's console appears:

[start] git push
onMessage error:GH007: Your push would publish a private email address.
onMessage You can make your email public or disable this protection by visiting:
onMessage https://github.com/settings/emails
GitPushError: One or more branches were not updated: 
  - refs/heads/main: push declined due to email privacy restrictions
    at gEe (index-03b654cd.js:456:40)
    at async Object.vEe [as push] (index-03b654cd.js:456:332)
    at async cDe (index-03b654cd.js:501:34563)
    at async push (index-03b654cd.js:614:5288)

Even if Lumen's repo is commonly used as a private repo, disabling "Keep my email addresses private" in Github is an undesired option for some people.

colebemis commented 20 hours ago

Thanks for reporting @UshiHiraga. Do you know what we could do in Lumen to fix this issue?

UshiHiraga commented 15 hours ago

I guess the problem is related with the way user's email is collected in the getUser() method in netlify/edge-functions/github-auth.ts

According to response schema of /user/emails endpoint, it is possible to check visibility in the email object.

// Example presented in github api docs.
[
  {
    "email": "octocat@github.com",
    "verified": true,
    "primary": true,
    "visibility": "public"
  }
]

The solution would be to collect the first primary email that is also "public". It'd be necessary to changes lines 72 and 73 to:

  const emails = (await emailResponse.json()) as Array<{ email: string; primary: boolean; visibility: string }>
  const primaryEmail = emails.find((email) => email.primary && email.visibility === "public")