Skip to content

feat(errors): add dedicated error type for blocked content #282

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

Closed
wants to merge 3 commits into from

Conversation

PsychoPunkSage
Copy link

Changes:

  • Add new ErrBlocked error type in errors.go
  • Handle HTTP 410 (Gone) and 451 (Unavailable For Legal Reasons) status codes in response parsing
  • Map blocked content errors to appropriate status codes in response emitter

This provides proper error types for content blocking rather than relying on string matching. Works in conjunction with error type improvements in boxo.

Inspired by: ipfs/boxo#591
Related to: ipfs/boxo#855

Signed-off-by: Abhinav Prakash <abhinav.prakash319@gmail.com>
Signed-off-by: Abhinav Prakash <abhinav.prakash319@gmail.com>
Signed-off-by: Abhinav Prakash <abhinav.prakash319@gmail.com>
Copy link

welcome bot commented Feb 22, 2025

Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure that:

  • The context for this PR is clear, with relevant discussion, decisions
    and stakeholders linked/mentioned.

  • Your contribution itself is clear (code comments, self-review for the
    rest) and in its best form. Follow the code contribution
    guidelines

    if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
Next steps:

  • A maintainer will triage and assign priority to this PR, commenting on
    any missing things and potentially assigning a reviewer for high
    priority items.

  • The PR gets reviews, discussed and approvals as needed.

  • The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution.
We are very grateful for your contribution!

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. We need to see how this will work in practice.
Namely, who throws ErrBlocked?

Similar request to ipfs/boxo#855 (review) – mind opening a companion PR against https://github.com/ipfs/kubo that uses go-ipfs-cmds from this PR and demonstrates how this should be used?

We have RPC/CLI tests in https://github.com/ipfs/kubo/blob/baa94fcb2f8ff0e23a9da8e7934c05ad5540afe5/test/cli/content_blocking_test.go#L186 that expect specific string.

What needs to be added is additional HTTP RPC test there that makes request to /api/v0/{cmd} and then inspects HTTP response code.

Once we have it in Kubo, we can enable it in this repository in .github/workflows/kubo-sharness.yml.

@gammazero
Copy link
Contributor

gammazero commented Mar 18, 2025

Closing to prefer a more unified error strategy + ipfs/boxo#855 (comment)

@gammazero gammazero closed this Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants