Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

backport: github: fix erratic 404s by keeping URL stable (#56478)#56495

Merged
BolajiOlajide merged 3 commits into
5.1from
backport-56478-to-5.1
Sep 11, 2023
Merged

backport: github: fix erratic 404s by keeping URL stable (#56478)#56495
BolajiOlajide merged 3 commits into
5.1from
backport-56478-to-5.1

Conversation

@mrnugget

Copy link
Copy Markdown
Contributor

**NOTE: This is a backport of https://github.com/sourcegraph/sourcegraph/pull/56478. cc @sourcegraph/release-guild **

See this comment and the issue it's in for full context.

Short version:

  1. GitHub v3 and v4 clients execute this bit of code multiple times when retrying a request after it ran into rate limits: https://github.com/sourcegraph/sourcegraph/blob/16458d7e5c07ac69d00d32841a1a7dcd55a50ddb/internal/extsvc/github/common.go#L1589-L1590
  2. When executed multiple times with the same url.URL, req.URL.Path ends up with invalid paths like /api/v3/api/v3

That lead to 404 errors showing up sometimes: when the client runs into rate limit and retries. And sometimes these 404s were even ignored and lead to a "successful" end of the syncing process.

This changes the behaviour of the clients to keep a copy of the original req.URL around so that modifications made by doRequest don't have unintended side-effects.

(cherry picked from commit 8e21962)

Test plan

  • N/A

See [this comment](sourcegraph/customer#2329 (comment))
and the issue it's in for full context.

Short version:

1. GitHub v3 and v4 clients execute this bit of code multiple times when retrying a request after it ran into rate limits: https://github.com/sourcegraph/sourcegraph/blob/16458d7e5c07ac69d00d32841a1a7dcd55a50ddb/internal/extsvc/github/common.go#L1589-L1590
2. When executed multiple times with the same `url.URL`, `req.URL.Path` ends up with invalid paths like `/api/v3/api/v3`

That lead to 404 errors showing up _sometimes_: when the client runs
into rate limit and retries. And _sometimes_ these 404s were even
ignored and lead to a "successful" end of the syncing process.

This changes the behaviour of the clients to keep a copy of the original
`req.URL` around so that modifications made by `doRequest` don't have
unintended side-effects.

(cherry picked from commit 8e21962)
@sourcegraph-bot

sourcegraph-bot commented Sep 11, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 6cb2ebe...5eeef62.

Notify File(s)
@eseliger internal/extsvc/github/v3.go
internal/extsvc/github/v3_test.go
internal/extsvc/github/v4.go
internal/extsvc/github/v4_test.go
@sashaostrikov internal/extsvc/github/v3.go
internal/extsvc/github/v3_test.go
internal/extsvc/github/v4.go
internal/extsvc/github/v4_test.go

@sourcegraph-bot

sourcegraph-bot commented Sep 11, 2023

Copy link
Copy Markdown
Contributor

📖 Storybook live preview

@BolajiOlajide BolajiOlajide enabled auto-merge (squash) September 11, 2023 09:25
@BolajiOlajide BolajiOlajide merged commit 27596b4 into 5.1 Sep 11, 2023
@BolajiOlajide BolajiOlajide deleted the backport-56478-to-5.1 branch September 11, 2023 09:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants