fix(a2a): preserve discovery name edit, default discovery headers, sync url on re-discover
Some checks are pending
Unit Tests: Proxy DB Operations / key-generation (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / assert-shard-coverage (push) Waiting to run
Unit Tests: Proxy DB Operations / auth-checks (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / budgets (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / custom-logging (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / db-and-spend (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / endpoints-and-responses (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / guardrails-hooks (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / jwt-and-keys (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / logging-misc (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / proxy-runtime (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / proxy-server-core (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / schema-migration (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / proxy-utils (push) Blocked by required conditions
Unit Tests: Security / security (push) Waiting to run

- _build_merged_agent_card: prefer card-supplied name over agent_name so
  the discovery panel's editable 'Name (shown to API clients)' value is
  not silently overwritten by the internal identifier.
- async_safe_get call in fetch_well_known_card: pass headers or {} to
  avoid TypeError({**None, 'Host': ...}) when URL validation is enabled
  in production (default).
- agent_info handleApplyDiscoveredCard: set url: selection.upstream_url
  in fieldsToSet so re-discovery during edit refreshes the form's URL
  field for pure A2A agents (matches add_agent_form).

Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
Cursor Agent 2026-05-28 07:38:12 +00:00
parent 1a9bce33be
commit 65484a831c
No known key found for this signature in database
3 changed files with 13 additions and 2 deletions

View file

@ -119,7 +119,12 @@ async def fetch_well_known_card(
# redirect hop. Even though the discovery endpoint is admin-only,
# we don't want a compromised admin key to be able to probe
# internal infrastructure through this fetcher.
response = await async_safe_get(client, url, headers=headers)
# Pass ``headers or {}`` because ``async_safe_get`` (in the
# URL-validation path) uses ``kwargs.pop("headers", {})`` which
# returns ``None`` when the key is present-but-None, then crashes
# on ``{**None, "Host": ...}``. Default the kwarg to an empty
# dict so production (``user_url_validation=True``) doesn't 500.
response = await async_safe_get(client, url, headers=headers or {})
except SSRFError as exc:
last_error = f"{url}: {exc!s}"
verbose_proxy_logger.debug(

View file

@ -52,11 +52,16 @@ def _build_merged_agent_card(
) -> Dict[str, Any]:
"""Apply the LiteLLM-fronting merge to ``upstream_card`` for ``agent_id``."""
proxy_base = _proxy_base_url(http_request)
# Prefer a card-supplied ``name`` (the discovery UI exposes an editable
# "Name (shown to API clients)" field that flows into
# ``agent_card_params.name``) over the internal ``agent_name`` identifier.
# Fall back to ``agent_name`` only when the card itself has no name.
card_name = upstream_card.get("name") if upstream_card else None
return merge_agent_card(
upstream_card,
proxy_url=f"{proxy_base}/a2a/{agent_id}",
proxy_base_url=proxy_base,
name=agent_name,
name=card_name or agent_name,
)

View file

@ -131,6 +131,7 @@ const AgentInfoView: React.FC<AgentInfoViewProps> = ({
const fieldsToSet: Record<string, any> = {
name: selected_card.name,
description: selected_card.description,
url: selection.upstream_url,
streaming: Boolean(selected_card.capabilities?.streaming),
skills,
iconUrl: selected_card.iconUrl,