codesandbox-client icon indicating copy to clipboard operation
codesandbox-client copied to clipboard

"We were not able to compare the content with the source, please refresh or report the issue."

Open congcongcong250 opened this issue 3 years ago • 4 comments
trafficstars

🐛 bug report

Preflight Checklist

  • [x] I have read the Contributing Guidelines for this project.
  • [x] I agree to follow the Code of Conduct that this project adheres to.
  • [x] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Description of the problem

My project is linked to a Github repo. After the previous commit, I could not load github tab at all. The error message is "We were not able to compare the content with the source, please refresh or report the issue." Screen Shot 2022-07-12 at 1 30 48 am

Screen Shot 2022-07-12 at 1 38 12 am

There seems to be 2 related issues:

  • https://github.com/codesandbox/codesandbox-client/issues/4751
  • https://github.com/codesandbox/codesandbox-client/discussions/4430

How has this issue affected you? What are you trying to accomplish?

Commit

To Reproduce

I donno. Quick commit and close the tab?

Link to sandbox: link

Your Environment

Software Name/Version
Сodesandbox 7baad8a9c
Browser Version 103.0.5060.114 (Official Build) (x86_64)
Operating System macOS Bug Sur 11.6.7

congcongcong250 avatar Jul 11 '22 15:07 congcongcong250

Hey there

Thank you for reporting. I haven't managed to reproduce the bug, have you tried wether deleting the sandbox and reimporting it from GitHub solves the issue?

--- original message --- On July 11, 2022, 5:38 PM GMT+2 @.*** wrote:

🐛 bug report

Preflight Checklist

I have read the Contributing Guidelines for this project.

I agree to follow the Code of Conduct that this project

adheres to.

I have searched the issue tracker for an issue that matches the one I want

to file, without success.

Description of the problem

My project is linked to a Github repo. After the previous commit, I could not load github tab at all.

The error message is "We were not able to compare the content with the source, please refresh or report the issue."

From bottom right, it seems the hash is 7baad8a9c, while in my github repo, there's no such hash. 🤔

There seems to be 2 related issues:

#4751

#4430

How has this issue affected you? What are you trying to accomplish?

Commit

To Reproduce

I donno. Quick commit and close the tab?

Link to sandbox: link

Your Environment Software Name/Version Сodesandbox Browser Version 103.0.5060.114 (Official Build) (x86_64) Operating System macOS Bug Sur 11.6.7

Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: @.***> --- end of original message ---

CodeSandboxTeam avatar Jul 12 '22 07:07 CodeSandboxTeam

Hi, I did try reimport with a new project and it works fine. 👍🏻

I kept the old one in order to give you folks an example to debug.

congcongcong250 avatar Jul 12 '22 13:07 congcongcong250

Hey there,

I'm glad you could unblock yourself. I have reported the issue and a fix will be out soon.

Thank you.

--- original message --- On July 12, 2022, 3:38 PM GMT+2 @.*** wrote:

Hi, I did try reimport with a new project and it works fine. 👍🏻

I kept the old one in order to give you folks an example to debug.

Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you commented.Message ID: @.***> --- end of original message ---

CodeSandboxTeam avatar Jul 13 '22 08:07 CodeSandboxTeam

Hello @CodeSandboxTeam,

Any update on this?

I also stepped into the same issue. Seems like this happened to me after I committed to the repository not from a codesandbox web client but from a local machine using git cli.

STR:

  1. import some project from github to codesandbox
  2. do few commits to the repo from codesandbox web client
  3. do few commits to the repo from your local machine
  4. open project in codesandobx
  5. observe We were not able to compare the content with the source, please refresh or report the issue. error message

What I see in devtools is that request to compare endpoint fails with 500 code.

Request URL: https://codesandbox.io/api/v1/sandboxes/o03urk/git/compare
Request Method: POST
Status Code: 500 

Payload:

{
  "base_ref": "175433a93b569e6b7df517e4e35c1ad2a458c6a4",
  "head_ref": "main",
  "include_contents": true
}

While the latest commit to the repo has hash f467249d2bc2d88dff81a1cf4ae857691a11335c (made from local machine), codesandbox web client tries to compare to 175433a93b569e6b7df517e4e35c1ad2a458c6a4 (last commit made from codesandbox web client).

timagixe avatar Aug 15 '22 13:08 timagixe

@CodeSandboxTeam

Hi everyone. I had also this issue and could fix it. I want to share my method. You can manually set a hash of latest commit from your github repo page and assign it to first variable in below code ( change undefined to your hash between quotes "" ), but you don't have to. Then run this code in the console which you opened from your codesandbox project page. Hope this helps you. File "fix-github" will be created in your repo, you can delete this file.

//JS Code to run in console

(async()=>{
    const your_explicit_latest_github_hash = undefined;
    let your_latest_github_hash;
    if (your_explicit_latest_github_hash) {
        your_latest_github_hash = your_explicit_latest_github_hash
    } else {
        const project_name = document.location.pathname.split('/').at(-1)
        const project_id = project_name.split('-').at(-1)
        const {data: {me: {personalWorkspaceId}}} = await fetch("https://codesandbox.io/api/graphql", {
            "headers": {
                "content-type": "application/json"
            },
            "body": "{\"query\":\"query AllTeams { me { personalWorkspaceId } }\"}",
            "method": "POST"
        }).then(resp=>resp.json())
        const {data: {original_git: {username, repo, branch}}} = await fetch(`https://codesandbox.io/api/v1/sandboxes/${project_name}?teamId=${personalWorkspaceId}`).then(resp=>resp.json())
        const url = `https://api.github.com/repos/${username}/${repo}/branches/${branch}`
        const {commit: {sha}} = await fetch(url).then(resp=>resp.json())
        your_latest_github_hash = sha
    }
    const data = {
        id: your_codesandbox_project_id,
        message: "fix codesandbox and github integration",
        changes: {
            added: [{
                path: "/fix-github",
                content: "This file is created to fix CodesandBox and Github integration problem. You can delete this file.",
                encoding: "utf-8"
            }],
            deleted: [],
            modified: []
        },
        "parent_commit_shas": [your_latest_github_hash]
    }
    const body = JSON.stringify(data)
    fetch(`https://codesandbox.io/api/v1/sandboxes/${your_codesandbox_project_id}/git/commit`, {
        "headers": {
            "content-type": "application/json;charset=UTF-8",
        },
        "body": body,
        "method": "POST",
    })

}
)()

israilbutdayev avatar Jan 03 '23 12:01 israilbutdayev