Title: bug(adagents): fetch_adagents can't resolve real MANAGERDOMAIN publishers whose ads.txt is behind a redirect, and its errors carry no HTTP status · Issue #1306 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: bug(adagents): fetch_adagents can't resolve real MANAGERDOMAIN publishers whose ads.txt is behind a redirect, and its errors carry no HTTP status · Issue #1306 · adcontextprotocol/adcp-client-python
X Title: bug(adagents): fetch_adagents can't resolve real MANAGERDOMAIN publishers whose ads.txt is behind a redirect, and its errors carry no HTTP status · Issue #1306 · adcontextprotocol/adcp-client-python
Description: Summary On 8.0.0, fetch_adagents fails for publishers that delegate through ads.txt MANAGERDOMAIN and serve ads.txt behind a redirect, which is common on managed hosting. The fallback fetches /ads.txt with follow_redirects=False and trea...
Open Graph Description: Summary On 8.0.0, fetch_adagents fails for publishers that delegate through ads.txt MANAGERDOMAIN and serve ads.txt behind a redirect, which is common on managed hosting. The fallback fetches /ads....
X Description: Summary On 8.0.0, fetch_adagents fails for publishers that delegate through ads.txt MANAGERDOMAIN and serve ads.txt behind a redirect, which is common on managed hosting. The fallback fetches /ads....
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/1306
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug(adagents): fetch_adagents can't resolve real MANAGERDOMAIN publishers whose ads.txt is behind a redirect, and its errors carry no HTTP status","articleBody":"## Summary\n\nOn 8.0.0, `fetch_adagents` fails for publishers that delegate through ads.txt `MANAGERDOMAIN` and serve ads.txt behind a redirect, which is common on managed hosting. The fallback fetches `/ads.txt` with `follow_redirects=False` and treats a 30x as \"no MANAGERDOMAIN found\". Separately, non-404 failures are raised as `AdagentsValidationError` with the status only in the message text. And `fetch_adagents` rejects the bare-entry files that `resolve_properties_for_agent(mode=\"permissive\")` exists to handle.\n\n## Reproduction (adcp 8.0.0)\n\nPart 1 uses the live publisher `recipetineats.com` (output captured 2026-10-02). Parts 2 and 3 use `httpx.MockTransport`.\n\n```python\nimport asyncio\n\nimport httpx\nfrom adcp import fetch_adagents\nfrom adcp.adagents import resolve_properties_for_agent\n\n\ndef first_line(exc):\n return f\"{type(exc).__name__}: {str(exc).splitlines()[0]}\"\n\n\nasync def main():\n # 1. Real publisher: MANAGERDOMAIN lives in an ads.txt served behind redirects.\n try:\n await fetch_adagents(\"recipetineats.com\")\n except Exception as exc:\n print(\"1.\", first_line(exc))\n async with httpx.AsyncClient(follow_redirects=True) as client:\n r = await client.get(\"https://recipetineats.com/ads.txt\")\n print(\" ads.txt chain:\", [str(h.url) for h in r.history] + [str(r.url)])\n print(\" directive:\", [l for l in r.text.splitlines() if l.lower().startswith(\"managerdomain\")])\n print(\" manager file agents:\", len((await fetch_adagents(\"cafemedia.com\"))[\"authorized_agents\"]))\n\n # 2. Non-404 failures: no status attribute, no fallback.\n seen = []\n\n def outage(request):\n seen.append(request.url.path)\n return httpx.Response(200, text=\"managerdomain=cafemedia.com\\n\") if request.url.path == \"/ads.txt\" else httpx.Response(503)\n\n async with httpx.AsyncClient(transport=httpx.MockTransport(outage)) as client:\n try:\n await fetch_adagents(\"example.com\", client=client)\n except Exception as exc:\n print(\"2.\", first_line(exc), \"| status_code attr:\", hasattr(exc, \"status_code\"), \"| requested:\", seen)\n\n # 3. A file the permissive resolver handles cannot be fetched.\n agent = \"https://sales.example-agent.com\"\n doc = {\"authorized_agents\": [{\"url\": agent, \"authorized_for\": \"Display\"}],\n \"properties\": [{\"property_id\": \"site\", \"property_type\": \"website\", \"name\": \"Site\",\n \"identifiers\": [{\"type\": \"domain\", \"value\": \"example.com\"}]}]}\n print(\"3. permissive resolver:\", [p[\"property_id\"] for p in resolve_properties_for_agent(doc, agent, mode=\"permissive\")])\n async with httpx.AsyncClient(transport=httpx.MockTransport(lambda r: httpx.Response(200, json=doc))) as client:\n try:\n await fetch_adagents(\"example.com\", client=client)\n except Exception as exc:\n print(\" fetch_adagents:\", first_line(exc))\n\n\nasyncio.run(main())\n```\n\nOutput:\n\n```text\n1. AdagentsNotFoundError: adagents.json not found for domain: www.recipetineats.com\n ads.txt chain: ['https://recipetineats.com/ads.txt', 'https://www.recipetineats.com/ads.txt', 'https://ads.adthrive.com/sites/55cb7e3b4bc841bd0c4ea577/ads.txt']\n directive: ['managerdomain=cafemedia.com']\n manager file agents: 1\n2. AdagentsValidationError: Failed to fetch adagents.json: HTTP 503 | status_code attr: False | requested: ['/.well-known/adagents.json']\n3. permissive resolver: ['site']\n fetch_adagents: AdagentsValidationError: Invalid adagents.json structure: Agent authorization must have exactly one of: properties, property_ids, property_tags, publisher_properties.\n```\n\nThe publisher's own `adagents.json` is a 404 (after the apex-to-www hop, which the SDK now follows). Its ads.txt names `cafemedia.com`, and `cafemedia.com`'s file resolves. The SDK never reads the directive because ads.txt sits behind two redirects. The first stays on the publisher's root domain. The second is one hop to a third-party host. That is the redirect pattern the IAB ads.txt specification permits: redirects within the root domain, plus a single hop to a host outside it.\n\nCode: `_fetch_ads_txt_managerdomains` (`adcp/adagents.py:783-832`, `follow_redirects=False` at 813/818). The fallback runs only on `AdagentsNotFoundError` (`adagents.py:917`). Other statuses raise `AdagentsValidationError(f\"Failed to fetch adagents.json: HTTP {status_code}\")` (`adagents.py:1291`). Strict structure validation runs inside the fetch (`adagents.py:1315`).\n\n## Why an adopter hits this\n\nEmbedded Sales Agent wraps the SDK in `fetch_adagents_permissive` (`src/services/adagents_fetch.py`, 381 LOC). It:\n\n- matches the strings `\"Failed to fetch adagents.json: HTTP \"` and `\"Agent authorization must have exactly one of\"`;\n- re-implements a pinned, per-hop ads.txt redirect walk;\n- imports the private `_parse_managerdomains` and `_ensure_safe_manager_domain`.\n\nIts tests patch the private `adcp.adagents._owned_pinned_client` and `_dns_validate_host`, because SDK-owned hops can't take an injected transport. Without the wrapper, these publishers show as \"no adagents.json\", and products can't bind to them.\n\n## Ask\n\n1. In the MANAGERDOMAIN fallback, follow ads.txt redirects under the IAB rule (any number of hops within the publisher's root domain, plus at most one hop off it). Use the same per-hop gates as #947: HTTPS only, `_dns_validate_host`, a fresh pinned client per hop, and a hop cap. If you'd rather not change the default, put it behind an opt-in flag (e.g. `follow_ads_txt_redirects=True`).\n2. Raise a typed error for non-2xx responses (e.g. `AdagentsHTTPError(AdagentsValidationError)` with `status_code` and `url`).\n3. Let callers fetch without strict structure validation (e.g. `fetch_adagents(..., validate_structure=False)`), so files that `validate_adagents_structure` and the permissive resolver can process are reachable.\n4. Make `parse_managerdomains` public, and give SDK-owned hops a public transport seam (e.g. a `transport_factory=` kwarg) for tests.\n\n","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-10-02T16:02:20Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/1306"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:96e68b6b-0882-2a3d-d025-2fb1409285da |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C324:25598F:C5A88F:106920E:6B00F5B3 |
| html-safe-nonce | 085f5fad3fff75a3dd4a2b8893a34470d095f96c6211574b5430cfa429a95f36 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzI0OjI1NTk4RjpDNUE4OEY6MTA2OTIwRTo2QjAwRjVCMyIsInZpc2l0b3JfaWQiOiIzODExMjk5MzkxMjMxMjkyODUxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 903232a48fceaecea380a646d1b1e92981edac64be799528c5a47f4bf184ead5 |
| hovercard-subject-tag | issue:5680002062 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/1306/issue_layout |
| twitter:image | https://opengraph.githubassets.com/85c15b1e08c5c3e1757764a2b47f08fdca36010c4e270c39d32e5f4c0601882f/adcontextprotocol/adcp-client-python/issues/1306 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/85c15b1e08c5c3e1757764a2b47f08fdca36010c4e270c39d32e5f4c0601882f/adcontextprotocol/adcp-client-python/issues/1306 |
| og:image:alt | Summary On 8.0.0, fetch_adagents fails for publishers that delegate through ads.txt MANAGERDOMAIN and serve ads.txt behind a redirect, which is common on managed hosting. The fallback fetches /ads.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bokelley |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git |
| octolytics-dimension-user_id | 221690821 |
| octolytics-dimension-user_login | adcontextprotocol |
| octolytics-dimension-repository_id | 1090305973 |
| octolytics-dimension-repository_nwo | adcontextprotocol/adcp-client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1090305973 |
| octolytics-dimension-repository_network_root_nwo | adcontextprotocol/adcp-client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width