internal/frontend: fix resultFromFetchRequest on 200
When a fetch request returns in a 200, it is possible that the fullPath
that is requested is not in that module. In that case, return the error
message for when we find a module path matching the full path prefix,
instead of a status 200.
Change-Id: I336ca3b260874caf7455eb620a20d9ef69c659e8
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/287292
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/frontend/fetch.go b/internal/frontend/fetch.go
index 173c197..f3dc314 100644
--- a/internal/frontend/fetch.go
+++ b/internal/frontend/fetch.go
@@ -239,7 +239,9 @@
// appropriate result is found, return. Otherwise, look at the next
// path.
case http.StatusOK:
- return fr, nil
+ if fr.err == nil {
+ return fr, nil
+ }
case http.StatusRequestTimeout:
// If the context timed out or was canceled before all of the requests
// finished, return an error letting the user to check back later. The