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

[BUG]: diff_url always return 404 #2820

Open
1 task done
theunreal opened this issue Mar 1, 2025 · 3 comments
Open
1 task done

[BUG]: diff_url always return 404 #2820

theunreal opened this issue Mar 1, 2025 · 3 comments
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented

Comments

@theunreal
Copy link

What happened?

Simply trying to access a diff of a PR, but it always return 404(works only for public repos).
All other APIs that require authentication work (List pull request for example).
Only when trying to access the diff URL,it doesn't, and return 404.
It is accessible using the browser under authenticated session, but the API - 404.

Any idea?

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
    if (req.method === 'POST') {
        const payload = req.body;

        if (payload.action === 'opened' && payload.pull_request) { // Process only 'opened' PR events
            const diffUrl = prData.diff_url;

            console.log(`New PR opened: #${prNumber} in ${repoOwner} ${repoName}`);
            console.log(`Diff URL: ${diffUrl}`);

            try {
                const diffResponse = await octokit.request({
                    method: 'GET',
                    url: diffUrl,
                    headers: {
                        'Accept': 'application/vnd.github.v3.diff' // Request raw diff
                    }
                });
}

Versions

"octokit": "^4.1.2",

Relevant log output

curl -H "Authorization: token github_pat_my_token_here" https://github.com/theunreal/codesight/pull/11.diff
Not Found%

Code of Conduct

  • I agree to follow this project's Code of Conduct
@theunreal theunreal added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Mar 1, 2025
Copy link

github-actions bot commented Mar 1, 2025

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339
Copy link
Member

Are you able to share the full request headers?

@theunreal
Copy link
Author

Are you able to share the full request headers?

Not sure what you mean, but the headers are mentioned in the script, excluded the token (used in octokit init)
Anyway, I think it's an issue with github API, or there is another way to access file diff that I don't know about. But I couldn't find a way to access the diff_url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented
Projects
Status: 🆕 Triage
Development

No branches or pull requests

2 participants