From e051f007fa47ff02ed73dab3625f101a1539c5b4 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 13 Sep 2022 19:26:01 +1000 Subject: [PATCH] fix: handle error AND zero-length cases from piece lookup --- retrievalmarket/impl/provider_pieces.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/retrievalmarket/impl/provider_pieces.go b/retrievalmarket/impl/provider_pieces.go index 4a7caf71..e7a782ea 100644 --- a/retrievalmarket/impl/provider_pieces.go +++ b/retrievalmarket/impl/provider_pieces.go @@ -64,9 +64,12 @@ func (p *Provider) getCommonPiecesFromIdentityCidLinks(payloadCID cid.Cid) ([]ci // for each link, query the dagstore for pieces that contain it for i, link := range links { piecesWithThisCid, err := p.dagStore.GetPiecesContainingBlock(link) - if len(piecesWithThisCid) == 0 { + if err != nil { return nil, fmt.Errorf("getting pieces for identity CID sub-link %s: %w", link, err) } + if len(piecesWithThisCid) == 0 { + return nil, fmt.Errorf("no pieces for identity CID sub-link %s", link) + } if i == 0 { pieces = append(pieces, piecesWithThisCid...) } else {