Repository navigation
Conversation
…gated challenge Adds a typed AdagentsBotMitigationError (direct ADCPError subclass) when _fetch_adagents_url receives HTTP 403 with a cf-mitigated: challenge or cf-mitigated: managed response header, distinguishing WAF bot-mitigation blocks from auth/other 403s. Closes #801 https://claude.ai/code/session_01CmYfKqiv5eePuh9xR8PuxB
…nError Fixes message hardcoding "challenge" when header was "managed". Adds mitigation_type attribute and passes it from the detection site. https://claude.ai/code/session_01CmYfKqiv5eePuh9xR8PuxB
…bot-mitigation test Addresses pre-PR reviewer nits: docstring now covers both challenge and managed cf-mitigated values; adds test asserting WAF-blocked domain is excluded from fetch_agent_authorizations result with a warning log. https://claude.ai/code/session_01CmYfKqiv5eePuh9xR8PuxB
| client=client, | ||
| ) | ||
|
|
||
| assert "open.example.com" in result |
|
|
||
| assert "open.example.com" in result | ||
| assert "blocked.example.com" not in result | ||
| assert any("blocked.example.com" in r.message for r in caplog.records) |
|
Correction to the prior close note: this variant broadened behavior to cf-mitigated: challenge or managed and left the exception-inheritance question unresolved. #816 is the narrower, backward-compatible path. |
|
Acknowledged — closure noted. #816's narrower scope and resolved inheritance question look like the right path for #801. Triaged by Claude Code. Session: https://claude.ai/code/session_01S8FTSnTgSQfkzyfzhdDN3X Generated by Claude Code |
|
Acknowledged — noted the correction. This PR broadened detection to Generated by Claude Code |
Closes #801
Summary
_fetch_adagents_urlcurrently raises a genericAdagentsValidationError: Failed to fetch adagents.json: HTTP 403when a publisher's Cloudflare WAF returnscf-mitigated: challengeorcf-mitigated: managed. This gives callers no way to distinguish a WAF bot-mitigation block from an auth error or other 403.This PR adds
AdagentsBotMitigationError— raised when HTTP 403 +cf-mitigatedheader is detected — with:publisher_domainattributemitigation_typeattribute (the actual cf-mitigated value:"challenge"or"managed")fetch_agent_authorizations_from_directory()or publisher allowlist coordinationPer the reframing in #801's comment thread, post-5.7.0 the impacted callers are: (1) the AAO directory crawler, (2) real-time re-verification callers, (3) dev/debug.
fetch_agent_authorizations_from_directory()is the recommended path for everyone else.What changed
src/adcp/exceptions.py: NewAdagentsBotMitigationError(ADCPError)— typed exception withpublisher_domainandmitigation_typeattributessrc/adcp/adagents.py:_fetch_adagents_url: detectstatus_code == 403+cf-mitigated: challenge|managedbefore generic non-200 handler_try_managerdomain_fallback: added to silent-return except tuplevalidate_adagents_domain(2 sites): added to "report on result" except tuplesfetch_agent_authorizations: explicitlogger.warning+ return(domain, None)before generic swallowsrc/adcp/__init__.py: exported in import block and__all__tests/fixtures/public_api_snapshot.json: regeneratedtests/test_adagents.py: 4 new tests (challenge, managed, plain-403 negative case, validate_adagents_domain capture)What tested
pytest tests/test_adagents.py tests/test_public_api.py— 210 passedruff check src/adcp/— cleanfrom adcp import AdagentsBotMitigationError✓Open design question — flagged for human review
Pre-PR experts disagreed on the inheritance of
AdagentsBotMitigationError:ad-tech-protocol-expert: inheriting from
ADCPErrordirectly (current impl) is a breaking inconsistency —AdagentsNotFoundErrorandAdagentsTimeoutErrorboth inherit fromAdagentsValidationError, and callers that catchAdagentsValidationErroras a cluster (e.g.verify_agent_for_property,fetch_adagents_with_cache) will not catch this error. RecommendsAdagentsBotMitigationError(AdagentsValidationError)for consistency.dx-expert:
AdagentsValidationErroris wrong conceptually — a WAF block is a transport-layer refusal, not a validation error. Callers that catchAdagentsValidationErrorgenerically would silently swallow it; the new error should propagate to force explicit handling.Both positions have merit. The current PR uses
ADCPErrordirectly (dx-expert position) and explicitly adds the new class to the four call-site except tuples that need it. Changing toAdagentsValidationErrorwould remove those four explicit catches but alter the error hierarchy semantics.Please resolve before merge.
Pre-PR review
mitigation_type), 1 design question flagged aboveSession: https://claude.ai/code/session_01CmYfKqiv5eePuh9xR8PuxB
Generated by Claude Code