extensions icon indicating copy to clipboard operation
extensions copied to clipboard

[GitHub] Notifications URL's are for API calls

Open theherk opened this issue 11 months ago • 6 comments

Extension

https://www.raycast.com/raycast/github

Raycast Version

1.88.4

macOS Version

15.2

Description

URL's generated for opening notifications are API URL's. They look something like https://api.github.com/notifications/threads/14063893845. This works for viewing notifications in the interface, but not for opening in browser. Opening in browser yields:

{
  "message": "Requires authentication",
  "documentation_url": "https://docs.github.com/rest/activity/notifications#get-a-thread",
  "status": "401"
}

Steps To Reproduce

  1. Open "Notifications" command.
  2. Try to open notification in browser.

Current Behaviour

Returns 401.

Expected Behaviour

Opens the correct web link in lieu of the API URL.

Important Note

I forgot to add the probably most important bit. This only applies to some repositories or notifications, but I'm unclear on what makes that difference. The link above is a publicly accessible repo and thread.

theherk avatar Dec 31 '24 10:12 theherk

Thank you for opening this issue!

🔔 @thomaslombart @unnamedd @tonka3000 @khasbilegt @pernielsentikaer @loxygenK @oilbeater @LunaticMuch @aeorge @daquinoaldo @peppy @aeither @marcotf @qeude @nesl247 @xilopaint @antonengelhardt @bangerang @wottpal @LitoMore @d-mitrofanov-v @j3lte @jfkisafk @vlasischar @JavaLangRuntimeException @shyakadavis @sushichan044 you might want to have a look.

💡 Author and Contributors commands

The author and contributors of raycast/github can trigger bot actions by commenting:

  • @raycastbot close this issue Closes the issue.
  • @raycastbot close as not planned Closes the issue as not planned.
  • @raycastbot rename this issue to "Awesome new title" Renames the issue.
  • @raycastbot reopen this issue Reopens the issue.
  • @raycastbot assign me Assigns yourself to the issue.
  • @raycastbot good first issue Adds the "Good first issue" label to the issue.
  • @raycastbot keep this issue open Make sure the issue won't go stale and will be kept open by the bot.

raycastbot avatar Dec 31 '24 10:12 raycastbot

Thanks for reporting this bug. Would you like to work on it? If yes, here's our guide on extension contributions so that you can open up a pull request. Feel free to contact me here or in the Slack community if you need further help.

thomaslombart avatar Jan 09 '25 10:01 thomaslombart

@theherk The action marks the notification as read and then opens it in the browser, so probably the former action fails and therefore also the latter. Can you share the type of notification (mentioned, review requested, ...)?

antonengelhardt avatar Jan 09 '25 12:01 antonengelhardt

async function openNotification(isUnreadNotification: boolean) {
    try {
      if (url) {
        await open(url);
      }

      if (isUnreadNotification) {
        await octokit.activity.markThreadAsRead({ thread_id: parseInt(notification.id) });
        await mutateList();
      }
    } catch (error) {
      await showToast({
        style: Toast.Style.Failure,
        title: "Failed opening notification",
        message: getErrorMessage(error),
      });
    }
  }

antonengelhardt avatar Jan 09 '25 12:01 antonengelhardt

It might also be interessting to know if you are authenticating with OAuth or with the GitHub Token in the extension settings:

Screenshot-Raycast-010384

antonengelhardt avatar Jan 09 '25 12:01 antonengelhardt

"CI Activity" notifications open, but "Commented" notifications give the error. The notification I gave above is a "State Changed" notification. I am logged in with oath, but I think I've also provided a token. Maybe not, but I can't tell since the box shows dots either way, I believe. I could add a token, but I suffer this issue in the Github Enterprise extension too, which is likely for the same reason, and that one I've definitely added a token for.

I contribute to several extensions, so maybe I'll try to carve out time for these two as well, but I'm not sure when.


Okay, yeah I just regenerated the token I thought I had used add verified it is added definitely. So I'm logged in with oauth and have given a token with the necessary scopes. Same issue.

theherk avatar Jan 10 '25 21:01 theherk

This issue has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 10 days to keep our backlog clean 😊

raycastbot avatar Mar 02 '25 03:03 raycastbot

This issue is still present, though I haven't had the time to address it further. Should probably stay open for posterity.

theherk avatar Mar 03 '25 07:03 theherk

This issue has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 10 days to keep our backlog clean 😊

raycastbot avatar Apr 22 '25 08:04 raycastbot

Just verified, issue is still present. When opening a notification in browser, the api link is used.

theherk avatar Apr 22 '25 08:04 theherk

Is this still an issue?

pernielsentikaer avatar Oct 16 '25 06:10 pernielsentikaer

Is this still an issue?

Yes, it is.

theherk avatar Oct 16 '25 07:10 theherk

I did a bit of a dive into the code, the problem should be fixed here: https://github.com/raycast/extensions/blob/bd74250085a6e680c43d79a4180695446b3accc7/extensions/github/src/helpers/notifications.ts#L40

  • If it has notification.subject.url it generates a browser url
  • If not, it creates a url when notification.subject.type === "CheckSuite"
  • If not, it creates a url when notification.subject.type === "Discussion"

else it returns just notification.url, which is a https://api.github.com url.

So, it either can't find the notification.subject.url, or we're dealing with a notification.subject.type that isn't caught in our if-else statements (it being 'CheckSuite' or 'Discussion')

Currently it's unclear to me what type of notification.subject.type we're dealing with. Since I don't have the issue myself (I can open 'Commented' notifications fine) I can't debug it.

@theherk I think it might be helpful to fork the extension, place a console.log(notification.subject) in the getGithubURL function and check what it says.

I'm digging a little further into the Github REST API docs to see what the type of notifications there are...

j3lte avatar Oct 17 '25 11:10 j3lte