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

Clicking on a notification navigates to the repository instead of the issue/pull request/etc. #1656

Closed
1 task done
axelrindle opened this issue Dec 5, 2024 · 6 comments
Closed
1 task done
Labels
bug Something isn't working host:github-cloud Related to GitHub Cloud

Comments

@axelrindle
Copy link

🔍 Is there already an issue for your problem?

  • I have checked older issues, open and closed

📝 Description

While the notifications per se are working fine, navigating to the source of the notification does not. Clicking on a notification immediately removes it from the list and brings me to the main repository page instead of the issue/pull request/etc.

🪜 Steps To Reproduce

  1. Receive a notification, e.g. be mentioned in an issue
  2. Click on the notification in gitify
  3. Land on the main repository page

Gitify Version

5.16.2

Operating System

macOS

GitHub Account

GitHub Cloud

📸 Screenshots

No response

@axelrindle axelrindle added the bug Something isn't working label Dec 5, 2024
@setchy
Copy link
Member

setchy commented Dec 5, 2024

Likely duplicate of #1645

Can you please check the logs to see where it is failing

@jkbe
Copy link

jkbe commented Dec 20, 2024

Hi, I have the same issue. Here are my logs for clicking on a notification about that a PR got merged that I participated in:

[2024-12-20 15:09:04.262] [error] Error occurred while fetching notification html url AxiosError: Request failed with status code 404
    at xe (file:///Applications/Gitify.app/Contents/Resources/app.asar/build/renderer.js:61:430304)
    at XMLHttpRequest.v (file:///Applications/Gitify.app/Contents/Resources/app.asar/build/renderer.js:61:434587)
    at ut.request (file:///Applications/Gitify.app/Contents/Resources/app.asar/build/renderer.js:61:442847)
    at async t.getHtmlUrl (file:///Applications/Gitify.app/Contents/Resources/app.asar/build/renderer.js:2:466433)
    at async t.generateGitHubWebUrl (file:///Applications/Gitify.app/Contents/Resources/app.asar/build/renderer.js:61:11660)
    at async t.openNotification (file:///Applications/Gitify.app/Contents/Resources/app.asar/build/renderer.js:61:17352)
[2024-12-20 15:09:04.262] [error] Error occurred while attempting to get a specific notification URL.  Will fall back to defaults TypeError: Failed to set the 'href' property on 'URL': Invalid URL
    at t.generateGitHubWebUrl (file:///Applications/Gitify.app/Contents/Resources/app.asar/build/renderer.js:61:11659)
    at async t.openNotification (file:///Applications/Gitify.app/Contents/Resources/app.asar/build/renderer.js:61:17352)

I think it's at least not quite the same issue as the one that you linked @setchy because not only is the fragment # missing but also the /pull/19 substring. The link URL displayed for the notification on github.com/notifications is:

https://github.com/<org>/<repo>/pull/19?notification_referrer_id=<redacted-string>#event-<redacted-event-id>

The URL that Gitify opens is:

https://github.com/<org>/<repo>?notification_referrer_id=<redacted-string>

I'm running Gitify v5.17.0 on macOS.

@setchy
Copy link
Member

setchy commented Dec 22, 2024

Thanks @JakobEdding - I agree, this is a different issue you and @axelrindle are facing.

Does this happen for all notification types, or only a subset?

The 404 error from the log above appears to be thrown in the below function, which takes a notifications comment url to resolve the html url.

export async function getHtmlUrl(url: Link, token: Token): Promise<string> {
try {
const response = (await apiRequestAuth(url, 'GET', token)).data;
return response.html_url;
} catch (err) {
log.error('Error occurred while fetching notification html url', err);
}
}

This is called in two places within our chain of notification html resolving

export async function generateGitHubWebUrl(
notification: Notification,
): Promise<Link> {
const url = new URL(notification.repository.html_url);
// FIXME see #1583
// Upstream GitHub API has started returning subject urls for Discussion notification types,
// however these URLs are broken. Temporarily downgrading to use discussion lookup process.
if (notification.subject.type === 'Discussion') {
notification.subject.url = null;
notification.subject.latest_comment_url = null;
}
try {
if (notification.subject.latest_comment_url) {
url.href = await getHtmlUrl(
notification.subject.latest_comment_url,
notification.account.token,
);
} else if (notification.subject.url) {
url.href = await getHtmlUrl(
notification.subject.url,
notification.account.token,
);
} else {
// Perform any specific notification type handling (only required for a few special notification scenarios)
switch (notification.subject.type) {
case 'CheckSuite':
url.href = getCheckSuiteUrl(notification);
break;
case 'Discussion':
url.href = await getDiscussionUrl(notification);
break;
case 'RepositoryInvitation':
url.pathname += '/invitations';
break;
case 'RepositoryDependabotAlertsThread':
url.pathname += '/security/dependabot';
break;
case 'WorkflowRun':
url.href = getWorkflowRunUrl(notification);
break;
default:
break;
}
}
} catch (err) {
log.error(
'Error occurred while attempting to get a specific notification URL. Will fall back to defaults',
err,
);
}
url.searchParams.set(
'notification_referrer_id',
generateNotificationReferrerId(notification),
);
return url.toString() as Link;
}

Running Gitify from source and debugging locally will be helpful to understanding why the exception is being thrown

@setchy setchy added the host:github-cloud Related to GitHub Cloud label Dec 22, 2024
@jkbe
Copy link

jkbe commented Dec 23, 2024

Thanks for your help! I just noticed in the FAQs what scopes Gitify requires the PAT to have. I reused an older PAT that only had the notification's scope enabled and nothing else. I extended the permissions now and everything works fine as expected.

@setchy
Copy link
Member

setchy commented Dec 23, 2024

Great to hear @JakobEdding 🥳

@axelrindle - perhaps this is also the same for your situation 🤞

@setchy
Copy link
Member

setchy commented Dec 25, 2024

Raised #1685 to help proactively notify users of mismatched scopes

For now I'll be closing this issue. Happy to reopen if there are other causes to triage.

@setchy setchy closed this as completed Dec 25, 2024
@setchy setchy reopened this Dec 26, 2024
@setchy setchy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working host:github-cloud Related to GitHub Cloud
Projects
None yet
Development

No branches or pull requests

3 participants