Skip to content

Fix diff fetch 404 error for private repositories#39

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/fix-pr-analysis-private-repos
Draft

Fix diff fetch 404 error for private repositories#39
Copilot wants to merge 1 commit intomainfrom
copilot/fix-pr-analysis-private-repos

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 7, 2026

PR analysis fails on private repos with "Diff fetch failed: Request failed with status code 404" at line 73 of analysis.service.js.

Root Cause

pr.diff_url returns a github.com URL (e.g., https://github.com/owner/repo/pull/123.diff) which requires browser-based authentication. API tokens via Authorization header don't work on these non-API URLs. GitHub returns 404 for security.

Changes

  • backend/services/analysis.service.js: Replace pr.diff_url fetch with GitHub API endpoint using Accept: application/vnd.github.v3.diff header

Before:

diffText = (
  await axios.get(pr.diff_url, {
    headers: ghHeaders,
    responseType: "text",
  })
).data;

After:

diffText = (
  await axios.get(
    `https://api.github.com/repos/${pr_owner}/${repo_name}/pulls/${pr_number}`,
    {
      headers: { 
        ...ghHeaders, 
        Accept: "application/vnd.github.v3.diff"
      },
      responseType: "text",
    }
  )
).data;

This pattern already works in analysePr.js controller for both public and private repos.

Original prompt

This section details on the original issue you should resolve

<issue_title>PR Analysis is failed for private repos</issue_title>
<issue_description>Image

@coderabbitai @copilot give a roadmap to fix the bug </issue_description>

<agent_instructions>do not fix on your own comment bellow issues regarding approach and actual cause of bug </agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix PR analysis failure for private repositories Fix diff fetch 404 error for private repositories Feb 7, 2026
Copilot AI requested a review from yb175 February 7, 2026 11:26
@yb175 yb175 closed this Feb 25, 2026
@yb175 yb175 reopened this Feb 25, 2026
@yb175 yb175 closed this Feb 26, 2026
@yb175 yb175 reopened this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PR Analysis is failed for private repos

2 participants