fix(adagents): raise AdagentsAccessBlockedError on 403 + cf-mitigated: challenge#816
Draft
bokelley wants to merge 5 commits into
Draft
fix(adagents): raise AdagentsAccessBlockedError on 403 + cf-mitigated: challenge#816bokelley wants to merge 5 commits into
bokelley wants to merge 5 commits into
Conversation
…: 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
…tsAccessBlockedError Refs #801
…tigated detection 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #801.
When
_fetch_adagents_urlreceives HTTP 403 withcf-mitigated: challenge, it now raisesAdagentsAccessBlockedError(aAdagentsValidationErrorsubclass) instead of the genericAdagentsValidationError. This makes the Cloudflare bot-challenge case distinguishable in application code without breaking existingexcept AdagentsValidationErrorhandlers.Changes
src/adcp/exceptions.py— newAdagentsAccessBlockedError(AdagentsValidationError)withpublisher_domainattribute and actionable suggestion textsrc/adcp/adagents.py— 403 +cf-mitigated: challengeguard inserted in_fetch_adagents_urlbetween the 404 and generic non-200 checks; new import addedsrc/adcp/__init__.py—AdagentsAccessBlockedErroradded to exports and__all__tests/test_adagents.py— three new tests: CF-mitigated 403 raises the subclass, plain 403 does not, subclass is catchable asAdagentsValidationErrortests/fixtures/public_api_snapshot.json—AdagentsAccessBlockedErroradded alphabeticallyDesign notes
AdagentsValidationError(notADCPErrordirectly) — existingexcept AdagentsValidationErrorcall sites catch it automatically; no call-site patches requiredcf-mitigated: challengeheader present; plain 403s still raise the generic errorTest plan
pytest tests/test_adagents.py -v -k "access_blocked or cf_mitigated or subclass_of_validation"— three new tests passpytest tests/— full suite greenmypy src/adcp/— no new type errorspython -c "from adcp import AdagentsAccessBlockedError; print(AdagentsAccessBlockedError.__mro__)"— confirms inheritance chainRefs #801
Generated by Claude Code