René's URL Explorer Experiment


Title: serve(transport="both") + callable public_url crashes at startup: 'function' object has no attribute 'router' · Issue #676 · adcontextprotocol/adcp-client-python · GitHub

Open Graph Title: serve(transport="both") + callable public_url crashes at startup: 'function' object has no attribute 'router' · Issue #676 · adcontextprotocol/adcp-client-python

X Title: serve(transport="both") + callable public_url crashes at startup: 'function' object has no attribute 'router' · Issue #676 · adcontextprotocol/adcp-client-python

Description: Repro def my_resolver(request): return f"https://{request.headers.get('host')}/" serve(handler, transport="both", public_url=my_resolver) Observed Process exits cleanly with code 0 at lifespan startup; uvicorn logs: ERROR: Application st...

Open Graph Description: Repro def my_resolver(request): return f"https://{request.headers.get('host')}/" serve(handler, transport="both", public_url=my_resolver) Observed Process exits cleanly with code 0 at lifespan star...

X Description: Repro def my_resolver(request): return f"https://{request.headers.get('host')}/" serve(handler, transport="both", public_url=my_resolver) Observed Process exits cleanly ...

Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/676

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"serve(transport=\"both\") + callable public_url crashes at startup: 'function' object has no attribute 'router'","articleBody":"## Repro\n\n```python\ndef my_resolver(request):\n    return f\"https://{request.headers.get('host')}/\"\n\nserve(handler, transport=\"both\", public_url=my_resolver)\n```\n\n## Observed\n\nProcess exits cleanly with code 0 at lifespan startup; uvicorn logs:\n\n```\nERROR:    Application startup failed. Exiting.\nAttributeError: 'function' object has no attribute 'router'\n```\n\nFull traceback:\n\n```\nFile \"/.venv/.../adcp/server/serve.py\", line 1705, in _composed_lifespan\n    async with a2a_inner.router.lifespan_context(a2a_inner):\n                ^^^^^^^^^^^^^^^^\nAttributeError: 'function' object has no attribute 'router'\n```\n\n## Root cause\n\nIn `_serve_mcp_and_a2a` (`adcp/server/serve.py`), the lifespan composer at lines 1702–1706 assumes both `mcp_inner` and `a2a_inner` are Starlette apps with `.router`:\n\n```python\nasync def _composed_lifespan(_app):\n    async with mcp_inner.router.lifespan_context(mcp_inner):\n        async with a2a_inner.router.lifespan_context(a2a_inner):\n            yield\n```\n\nBut `a2a_inner` is assigned from `create_a2a_server(..., public_url=public_url)` (line 1672). When `public_url` is a callable, `create_a2a_server` returns the `_wrap_with_per_request_card` middleware function (an `async def _middleware(scope, receive, send): ...`), not a Starlette app. The middleware has no `.router`.\n\nThe string and `None` cases pass `create_a2a_server`'s \"use the static URL or the bound localhost\" branch and return a Starlette app — that's why `transport=\"a2a\"` alone works (it doesn't go through `_composed_lifespan`) and `transport=\"both\"` works with non-callable `public_url`.\n\n## Impact\n\nAdopters following the docstring's per-tenant `PublicUrlResolver` pattern (parity with JS `createTenantRegistry`) on the unified MCP+A2A binary can't actually use the feature. Drove ~half a day of debugging on our side, including a CI run where every E2E and quickstart job timed out on \"Server did not become healthy in time\" because the container exited 0 instead of crashing loud.\n\n## Suggested fix\n\nEither:\n\n1. **Have `_wrap_with_per_request_card` wrap the inner app instead of replacing it.** Keep `a2a_inner` as the Starlette app `create_a2a_server` would have built with `public_url=None`, then layer the per-request handler as middleware. The lifespan composer keeps working unchanged.\n\n2. **Or make `_composed_lifespan` reach for the underlying app.** When `a2a_inner` doesn't have `.router`, walk a known attribute (`.app`, or store the inner reference on the wrapper).\n\nOption 1 keeps the lifespan composer trivial; option 2 is a local fix.\n\n## Workaround\n\nPass `public_url` as a string (e.g. from `PUBLIC_URL` env) and run your own ASGI middleware to rewrite `/.well-known/agent-card.json` from `X-Forwarded-Host` — same as the pre-5.1 pattern. We restored our 189-line `AgentCardPublicUrlMiddleware` for exactly this.\n\n## Environment\n\n- `adcp==5.2.0`\n- Python 3.12\n- `transport=\"both\"`, multi-tenant subdomain deployment","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-05-11T20:13:05Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/676"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0185adf0-b118-6e43-decb-f2719712a7aa
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8A66:26ECEB:FC5078:143CA12:6B00FEFE
html-safe-nonce3dfd3ab91172f8ba405c0fc275d3ee1267b6308c4728b61984167afd9087bdf4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTY2OjI2RUNFQjpGQzUwNzg6MTQzQ0ExMjo2QjAwRkVGRSIsInZpc2l0b3JfaWQiOiIyOTQwNDI4NTk1MTExMTk4NDYzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacbbafdae8f701e55e781b1b911f4995276ff3fb551c26be6c298023b5a57d6858
hovercard-subject-tagissue:4423964831
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/676/issue_layout
twitter:imagehttps://opengraph.githubassets.com/305bf257a503c90f1afce753d542a2fb13e871b50e594b00518a71cd341f7073/adcontextprotocol/adcp-client-python/issues/676
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/305bf257a503c90f1afce753d542a2fb13e871b50e594b00518a71cd341f7073/adcontextprotocol/adcp-client-python/issues/676
og:image:altRepro def my_resolver(request): return f"https://{request.headers.get('host')}/" serve(handler, transport="both", public_url=my_resolver) Observed Process exits cleanly with code 0 at lifespan star...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebokelley
hostnamegithub.com
expected-hostnamegithub.com
Nonecb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124
turbo-cache-controlno-preview
go-importgithub.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git
octolytics-dimension-user_id221690821
octolytics-dimension-user_loginadcontextprotocol
octolytics-dimension-repository_id1090305973
octolytics-dimension-repository_nwoadcontextprotocol/adcp-client-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1090305973
octolytics-dimension-repository_network_root_nwoadcontextprotocol/adcp-client-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/adcontextprotocol/adcp-client-python/issues/676#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fadcontextprotocol%2Fadcp-client-python%2Fissues%2F676
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fadcontextprotocol%2Fadcp-client-python%2Fissues%2F676
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=adcontextprotocol%2Fadcp-client-python
Reloadhttps://github.com/adcontextprotocol/adcp-client-python/issues/676
Reloadhttps://github.com/adcontextprotocol/adcp-client-python/issues/676
Reloadhttps://github.com/adcontextprotocol/adcp-client-python/issues/676
adcontextprotocolhttps://github.com/adcontextprotocol
adcp-client-pythonhttps://github.com/adcontextprotocol/adcp-client-python
Codehttps://github.com/adcontextprotocol/adcp-client-python
Issues44 (44)https://github.com/adcontextprotocol/adcp-client-python/issues
Pull requests13 (13)https://github.com/adcontextprotocol/adcp-client-python/pulls
Actionshttps://github.com/adcontextprotocol/adcp-client-python/actions
Projectshttps://github.com/adcontextprotocol/adcp-client-python/projects
Security and qualityhttps://github.com/adcontextprotocol/adcp-client-python/security
Insightshttps://github.com/adcontextprotocol/adcp-client-python/insights
https://github.com/adcontextprotocol/adcp-client-python
New issuehttps://github.com/login?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/676
New issuehttps://github.com/login?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/676
#682https://github.com/adcontextprotocol/adcp-client-python/pull/682
#680https://github.com/adcontextprotocol/adcp-client-python/pull/680
serve(transport="both") + callable public_url crashes at startup: 'function' object has no attribute 'router'https://github.com/adcontextprotocol/adcp-client-python/issues/676#top
#682https://github.com/adcontextprotocol/adcp-client-python/pull/682
#680https://github.com/adcontextprotocol/adcp-client-python/pull/680
claude-triagedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaged%22
https://github.com/bokelley
bokelleyhttps://github.com/bokelley
on May 11, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/676#issue-4423964831
bokelleyhttps://github.com/bokelley
claude-triagingTriage routine is actively working on this issue (1-3 min)https://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaging%22
claude-triagedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaged%22
claude-triagingTriage routine is actively working on this issue (1-3 min)https://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaging%22
on May 11, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/676#event-25402007685
https://github.com/bokelley
bokelleyhttps://github.com/bokelley
on May 11, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/676#issuecomment-4425255034
#681https://github.com/adcontextprotocol/adcp-client-python/pull/681
https://claude.ai/code/session_01He3UUyDxcy4pmyExJKCHNYhttps://claude.ai/code/session_01He3UUyDxcy4pmyExJKCHNY
Claude Codehttps://claude.ai/code
bokelleyhttps://github.com/bokelley
completedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#680https://github.com/adcontextprotocol/adcp-client-python/pull/680
on May 12, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/676#event-25408382535
KonstantinMirinhttps://github.com/KonstantinMirin
on May 13, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/676#event-25486674764
fix(server): preserve Starlette lifespan when public_url is callable (a…https://github.com/KonstantinMirin/adcp-client-python/commit/86328470ff9b53f6837368edd14851c16032efa7
a…https://github.com/adcontextprotocol/adcp-client-python/pull/680
https://docs.github.com/articles/closing-issues-via-commit-messages
8632847https://github.com/KonstantinMirin/adcp-client-python/commit/86328470ff9b53f6837368edd14851c16032efa7
Sign up for freehttps://github.com/signup?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/676
Sign in to commenthttps://github.com/login?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/676
claude-triagedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaged%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.