Skip to content

Commit

Permalink
docs: ipip-412 changelog and better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Jul 13, 2023
1 parent 65cc6a8 commit 8efec25
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
28 changes: 20 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,29 @@ The following emojis are used to highlight certain changes:
### Added

* ✨ The gateway now supports the optional `order` and `dups` CAR parameters
from [IPIP-412](https://github.com/ipfs/specs/pull/412). `BlocksBackend` only
DFS ordering. If the request explicitly requests an ordering other than `dfs`
and `unk`, the request will return an error.
from [IPIP-412](https://github.com/ipfs/specs/pull/412).
* The `BlocksBackend` only implements `order=dfs` (Depth-First Search)
ordering, which was already the default behavior.
* If a request specifies no `dups`, response with `dups=n` is returned, which
was already the default behavior.
* If a request explicitly specifies a CAR `order` other than `dfs`, it will
result in an error.
* The only change to the default behavior on CAR responses is that we follow
IPIP-412 and make `order=dfs;dups=n` explicit in the returned
`Content-Type` HTTP header.

### Changed

* 🛠 The `ipns` package has been refactored. You should no longer use the direct Protobuf
version of the IPNS Record. Instead, we have a shiny new `ipns.Record` type that wraps
all the required functionality to work the best as possible with IPNS v2 Records. Please
check the [documentation](https://pkg.go.dev/github.com/ipfs/boxo/ipns) for more information,
and follow [ipfs/specs#376](https://github.com/ipfs/specs/issues/376) for related IPIP.
* 🛠 The `ipns` package has been refactored.
* You should no longer use the direct Protobuf version of the IPNS Record.
Instead, we have a shiny new `ipns.Record` type that wraps all the required
functionality to work the best as possible with IPNS v2 Records. Please
check the [documentation](https://pkg.go.dev/github.com/ipfs/boxo/ipns) for
more information, and follow
[ipfs/specs#376](https://github.com/ipfs/specs/issues/376) for related
IPIP.
* There is no change to IPNS Records produced by `boxo/ipns`, it still
produces both V1 and V2 signatures by default, it is still backward-compatible.

### Removed

Expand Down
2 changes: 1 addition & 1 deletion gateway/blocks_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (bb *BlocksBackend) GetCAR(ctx context.Context, p ImmutablePath, params *Ca
case DagOrderDFS:

Check warning on line 242 in gateway/blocks_backend.go

View check run for this annotation

Codecov / codecov/patch

gateway/blocks_backend.go#L242

Added line #L242 was not covered by tests
// Do nothing
default:
return ContentPathMetadata{}, nil, fmt.Errorf("unsupported order: %s", params.Order)
return ContentPathMetadata{}, nil, fmt.Errorf("unsupported application/vnd.ipld.car block order parameter: %q", params.Order)

Check warning on line 245 in gateway/blocks_backend.go

View check run for this annotation

Codecov / codecov/patch

gateway/blocks_backend.go#L244-L245

Added lines #L244 - L245 were not covered by tests
}

// Similarly, if params.Duplicates is not set, let's set it to false.
Expand Down
8 changes: 4 additions & 4 deletions gateway/handler_car.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func getCarParams(r *http.Request, formatParams map[string]string) (*CarParams,
if hasRange {
rng, err := NewDagByteRange(rangeStr)
if err != nil {
err = fmt.Errorf("invalid entity-bytes: %w", err)
err = fmt.Errorf("invalid application/vnd.ipld.car entity-bytes URL parameter: %w", err)
return nil, err
}
params.Range = &rng
Expand All @@ -133,7 +133,7 @@ func getCarParams(r *http.Request, formatParams map[string]string) (*CarParams,
case DagScopeEntity, DagScopeAll, DagScopeBlock:
params.Scope = s
default:
err := fmt.Errorf("unsupported dag-scope %s", scopeStr)
err := fmt.Errorf("unsupported application/vnd.ipld.car dag-scope URL parameter: %q", scopeStr)
return nil, err
}
} else {
Expand All @@ -146,7 +146,7 @@ func getCarParams(r *http.Request, formatParams map[string]string) (*CarParams,
case "":
params.Order = DagOrderUnknown
default:
return nil, fmt.Errorf("unsupported order %s", order)
return nil, fmt.Errorf("unsupported application/vnd.ipld.car content type order parameter: %q", order)

Check warning on line 149 in gateway/handler_car.go

View check run for this annotation

Codecov / codecov/patch

gateway/handler_car.go#L148-L149

Added lines #L148 - L149 were not covered by tests
}

switch dups := formatParams["dups"]; dups {
Expand All @@ -159,7 +159,7 @@ func getCarParams(r *http.Request, formatParams map[string]string) (*CarParams,
case "":
// Acceptable, we do not set anything.
default:
return nil, fmt.Errorf("unsupported dups %s", dups)
return nil, fmt.Errorf("unsupported application/vnd.ipld.car content type dups parameter: %q", dups)

Check warning on line 162 in gateway/handler_car.go

View check run for this annotation

Codecov / codecov/patch

gateway/handler_car.go#L161-L162

Added lines #L161 - L162 were not covered by tests
}

return &params, nil
Expand Down

0 comments on commit 8efec25

Please sign in to comment.