Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gateway panic because of overshadowed err #511

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ The following emojis are used to highlight certain changes:
### Changed

### Removed

* 🛠 `boxo/gateway`: removed support for undocumented legacy `ipfs-404.html`. Use [`_redirects`](https://specs.ipfs.tech/http-gateways/web-redirects-file/) instead.

### Fixed

* `boxo/gateway`: a panic (which is recovered) could sporadically be triggered inside a CAR request, if the right [conditions were met](https://github.com/ipfs/boxo/pull/511).

### Security

## [v0.15.0]
Expand Down
9 changes: 6 additions & 3 deletions gateway/blocks_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@
var emptyRoot = []cid.Cid{cid.MustParse("bafkqaaa")}

func (bb *BlocksBackend) GetCAR(ctx context.Context, p path.ImmutablePath, params CarParams) (ContentPathMetadata, io.ReadCloser, error) {
pathMetadata, err := bb.ResolvePath(ctx, p)
if err != nil {
pathMetadata, resolveErr := bb.ResolvePath(ctx, p)
if resolveErr != nil {
rootCid, err := cid.Decode(strings.Split(p.String(), "/")[2])
if err != nil {
return ContentPathMetadata{}, nil, err
Expand Down Expand Up @@ -327,8 +327,11 @@
LastSegment: path.FromCid(rootCid),
ContentType: "",
}, io.NopCloser(&buf), nil
} else if err != nil {
return ContentPathMetadata{}, nil, err
} else {
return ContentPathMetadata{}, nil, resolveErr

Check warning on line 333 in gateway/blocks_backend.go

View check run for this annotation

Codecov / codecov/patch

gateway/blocks_backend.go#L330-L333

Added lines #L330 - L333 were not covered by tests
}
return ContentPathMetadata{}, nil, err
}

if p.Namespace() != path.IPFSNamespace {
Expand Down
Loading