Skip to content

gateway: dedicated error type for denylists #591

@aschmahmann

Description

@aschmahmann

Right now we don't use proper error types to convey that some content requested by a gateway was blocked. Instead we have this string based checking tied to nopfs

boxo/gateway/errors.go

Lines 211 to 216 in b101ba0

// isErrContentBlocked returns true for content filtering system errors
func isErrContentBlocked(err error) bool {
// TODO: we match error message to avoid pulling nopfs as a dependency
// Ref. https://github.com/ipfs-shipyard/nopfs/blob/cde3b5ba964c13e977f4a95f3bd8ca7d7710fbda/status.go#L87-L89
return strings.Contains(err.Error(), "blocked and cannot be provided")
}

@MichaelMure recently let me know that:

  1. Infura also does some string based error checking for their errors
  2. They return 451 when rather than just 410

So it seems to me like this should be bundled into boxo tooling.

  1. Have an error type indicating that it's a blocked error (which other tools like nopfs or others can wrap)
  2. Given that 451 and 410 both seem plausible either that should be configurable by the error tooling, or at the gateway level
    • At the moment I don't know anyone mixing 410s + 451s but that may not always be the case

@MichaelMure let me know if there's any context I missed.

cc @lidel

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: Good to have, but can wait until someone steps updif/mediumPrior experience is likely helpfulkind/enhancementA net-new feature or improvement to an existing featuretopic/gatewayIssues related to HTTP Gateway

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions