From 0eeccf082fa68b8e061bdd376a923e04d6073d0f Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Thu, 26 Aug 2021 05:51:46 -0400 Subject: internal/fetchdatasource: GetUnitMeta returns NotFound on missing package If a module exists but the package path is not in it, return NotFound. For golang/go#47780 Change-Id: If3a6602df4b99c8470020e8538e01c685880d86d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/345251 Trust: Jonathan Amsterdam Run-TryBot: Jonathan Amsterdam TryBot-Result: kokoro Reviewed-by: Jamal Carvalho Reviewed-by: Julie Qiu --- internal/fetchdatasource/fetchdatasource.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'internal/fetchdatasource/fetchdatasource.go') diff --git a/internal/fetchdatasource/fetchdatasource.go b/internal/fetchdatasource/fetchdatasource.go index 69f803eb..fe2eacca 100644 --- a/internal/fetchdatasource/fetchdatasource.go +++ b/internal/fetchdatasource/fetchdatasource.go @@ -181,10 +181,12 @@ func (ds *FetchDataSource) GetUnitMeta(ctx context.Context, path, requestedModul Path: path, ModuleInfo: module.ModuleInfo, } - if u := findUnit(module, path); u != nil { - um.Name = u.Name - um.IsRedistributable = u.IsRedistributable + u := findUnit(module, path) + if u == nil { + return nil, derrors.NotFound } + um.Name = u.Name + um.IsRedistributable = u.IsRedistributable return um, nil } -- cgit v1.3