From 66a76d27f36f202f006a6fe04809df1a3529a3be Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 30 Jul 2021 11:34:15 -0700 Subject: [PATCH] fix: abort when we fail to resolve CIDs I believe we figured that these were for "informational purposes", but really, we _should_ always be able to resolve names to CIDs. If we can't, there's probably something wrong with the directory. --- core/corehttp/gateway_handler.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index ccec95b01..8e8300b65 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -391,11 +391,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request size = humanize.Bytes(uint64(s)) } - hash := "" - if r, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name())); err == nil { - // Path may not be resolved. Continue anyways. - hash = r.Cid().String() + resolved, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name())) + if err != nil { + internalWebError(w, err) + return } + hash := resolved.Cid().String() // See comment above where originalUrlPath is declared. di := directoryItem{