Skip to content

fix(adagents): raise AdagentsAccessBlockedError on 403 + cf-mitigated: challenge#816

Draft
bokelley wants to merge 5 commits into
mainfrom
claude/issue-801-bot-mitigation-error
Draft

fix(adagents): raise AdagentsAccessBlockedError on 403 + cf-mitigated: challenge#816
bokelley wants to merge 5 commits into
mainfrom
claude/issue-801-bot-mitigation-error

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

Summary

Closes #801.

When _fetch_adagents_url receives HTTP 403 with cf-mitigated: challenge, it now raises AdagentsAccessBlockedError (a AdagentsValidationError subclass) instead of the generic AdagentsValidationError. This makes the Cloudflare bot-challenge case distinguishable in application code without breaking existing except AdagentsValidationError handlers.

Changes

  • src/adcp/exceptions.py — new AdagentsAccessBlockedError(AdagentsValidationError) with publisher_domain attribute and actionable suggestion text
  • src/adcp/adagents.py — 403 + cf-mitigated: challenge guard inserted in _fetch_adagents_url between the 404 and generic non-200 checks; new import added
  • src/adcp/__init__.pyAdagentsAccessBlockedError added to exports and __all__
  • tests/test_adagents.py — three new tests: CF-mitigated 403 raises the subclass, plain 403 does not, subclass is catchable as AdagentsValidationError
  • tests/fixtures/public_api_snapshot.jsonAdagentsAccessBlockedError added alphabetically

Design notes

  • Inherits from AdagentsValidationError (not ADCPError directly) — existing except AdagentsValidationError call sites catch it automatically; no call-site patches required
  • Only fires when both conditions hold: status 403 and cf-mitigated: challenge header present; plain 403s still raise the generic error
  • Non-breaking: all existing exception handling continues to work

Test plan

  • pytest tests/test_adagents.py -v -k "access_blocked or cf_mitigated or subclass_of_validation" — three new tests pass
  • pytest tests/ — full suite green
  • mypy src/adcp/ — no new type errors
  • python -c "from adcp import AdagentsAccessBlockedError; print(AdagentsAccessBlockedError.__mro__)" — confirms inheritance chain

Refs #801


Generated by Claude Code

bokelley added 5 commits May 22, 2026 14:05
…: challenge

When _fetch_adagents_url receives a 403 with the Cloudflare bot-management
response header cf-mitigated: challenge, raise the new typed subclass
AdagentsAccessBlockedError (extends AdagentsValidationError) with an
actionable suggestion pointing devs to either use a browser UA or the
directory API. Plain 403s without the header continue to raise the generic
error. Production buyers using fetch_agent_authorizations_from_directory
are unaffected.

Refs #801
…nd add publisher_domain attr

- Replace wrong function name fetch_agent_authorizations_from_directory()
  with fetch_agent_authorizations() (correct public API)
- Replace "buyers" terminology with "SDK callers" (domain-neutral)
- Add self.publisher_domain attribute so err.publisher_domain is accessible
- Tighten suggestion prose: remove AAO qualifier (function already implies it)

Refs #801
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.

bug(adagents): cafemedia.com (Raptive AAO file) blocks SDK with HTTP 403 — Cloudflare challenge on httpx client fingerprint

1 participant