octokit / plugin-rest-endpoint-methods.js

Octokit plugin adding one method for all of api.github.com REST API endpoints
MIT License
117 stars 56 forks source link

[BUG]: createOrUpdateFileContents results in error 504 #702

Open jp-bennett opened 11 months ago

jp-bennett commented 11 months ago

What happened?

Using the createOrUpdateFileContents in a the pull-request-artifacts action is failing to upload, and returning a 504 error, and the message "Error: We couldn't respond to your request in time. Sorry about that. Please try resubmitting your request and contact us if the problem persists."

Versions

plugin-rest-endpoint-methods 10.1.2

Relevant log output

Run gavv/pull-request-artifacts@v2.1.0
Artifacts repo: meshtastic/artifacts
Artifacts branch: device
Artifacts prefix: "pr2739-"
Processing artifact: ./firmware-2.2.16.d952da8.zip
GET /repos/meshtastic/artifacts/contents/.?ref=device - 200 in 264ms
Uploading file pr2739-firmware-2.2.16.d952da8.zip (first time)
PUT /repos/meshtastic/artifacts/contents/pr2739-firmware-2.2.16.d952da8.zip - 504 in 11150ms
Error: We couldn't respond to your request in time. Sorry about that. Please try resubmitting your request and contact us if the problem persists.

Code of Conduct

github-actions[bot] commented 11 months ago

👋 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 labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

jp-bennett commented 11 months ago

I'm also seeing a 502 error: Uploading file pr2998-firmware-2.2.16.0792274.zip (first time)

22PUT /repos/meshtastic/artifacts/contents/pr2998-firmware-2.2.16.0792274.zip - 502 in 12451ms

23Error: Server Error

wolfy1339 commented 11 months ago

Can you share a code snippet demonstratimg the issue?

jp-bennett commented 11 months ago

@wolfy1339 Sure. So we're seeing this while using https://github.com/gavv/pull-request-artifacts and an example CI run is at https://github.com/meshtastic/firmware/actions/runs/7185520403/job/19573992603#step:13:24

That code is at https://github.com/gavv/pull-request-artifacts/blob/main/src/main.ts#L147


      file_path: string,
      file_content: Buffer
    ): Promise<string> => {
      const old_sha = await findFileSha(file_path)

      if (old_sha) {
        core.info(`Uploading file ${file_path} (old sha ${old_sha})`)
      } else {
        core.info(`Uploading file ${file_path} (first time)`)
      }

      const repo_url = `https://github.com/${context.repo.owner}/${context.repo.repo}`
      const short_sha = commit_sha.substring(0, 5)

      let message = `Upload ${file_path} (${short_sha})`

      if (inter_link) {
        message += `

Pull request: ${repo_url}/pull/${context.issue.number}
Commit: ${repo_url}/commit/${commit_sha}
`
      }

      await artifacts_octokit.rest.repos.createOrUpdateFileContents({
        owner: artifacts_owner,
        repo: artifacts_repo,
        path: file_path,
        message,
        content: file_content.toString('base64'),
        branch: artifacts_branch,
        sha: old_sha
      })

      const artifacts_repo_url = `https://github.com/${artifacts_owner}/${artifacts_repo}`
      return `${artifacts_repo_url}/blob/${artifacts_branch}/${file_path}?raw=true`
    }```