You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cmd/go/internal/modfetch/codehost: treat nonexistent repositories as “not found”
If a go-import directive refers to a nonexistent repository, today we
treat that as an error fetching a module that actually exists.
That makes the HTTP server responsible for determining which
repositories do or do not exist, which may in general depend on
the user's separately-stored credentials, and imposes significant
complexity on such a server, which can otherwise be very simple.
Instead, check the repository URL and/or error message to try to
determine whether the repository exists at all. If the repo does not
exist, treat its absence as a “not found” error — as if the server had
not returned it in the first place.
Updates #34094
Change-Id: I142619ff43b96d0de428cdd0b01cca828c9ba234
Reviewed-on: https://go-review.googlesource.com/c/go/+/194561
Reviewed-by: Jay Conrod <[email protected]>
ifbytes.Contains(rerr.Stderr, []byte("fatal: could not read Username")) {
173
186
rerr.HelpText="Confirm the import path was entered correctly.\nIf this is a private repository, see https://golang.org/doc/faq#git_https for additional information."
174
187
}
175
188
}
176
-
r.refsErr=err
189
+
190
+
// If the remote URL doesn't exist at all, ideally we should treat the whole
191
+
// repository as nonexistent by wrapping the error in a notExistError.
192
+
// For HTTP and HTTPS, that's easy to detect: we'll try to fetch the URL
0 commit comments