Skip to content

[Bug]: A2ACardResolver fallback URL logic is wrong — no fallback when user provides the full card URL, and loses the original URL otherwise #1178

Closed

Description

@ehsavoie

What happened?

A2ACardResolver.resolveUrls() computes a fallbackUrl used when the primary card URL returns a 404. The current logic is:

String fallbackUrl = isSameUrl(cardUrl, originalBase) ? null : cleanBase;

This has two problems:

  1. No fallback when the user provides the full card URL as baseUrl

When a user passes http://example.com/.well-known/agent-card.json as baseUrl, cleanBase strips the well-known suffix to http://example.com, and cardUrl is recomputed to the same well-known URL. Since isSameUrl(cardUrl, originalBase) is true, fallbackUrl is set to null — the resolver gives up immediately on a 404 with no fallback attempt. It should fall back to cleanBase (http://example.com).

The same applies when a tenant card URL is passed with the matching tenant (e.g., baseUrl = "http://example.com/.well-known/acme/agent-card.json" with tenant = "acme").

  1. Fallback uses cleanBase instead of the user's original URL

When isSameUrl is false (the normal case), the fallback is cleanBase — a sanitized version of the URL with trailing slashes stripped and well-known suffixes removed. This discards the URL the user actually provided. If the user passed a specific URL expecting it to be tried as a fallback, the resolver silently rewrites it.

Expected behavior:

String fallbackUrl = isSameUrl(cardUrl, originalBase) ? cleanBase : originalBase;

  • When the computed card URL matches what the user provided: fall back to the cleaned base URL (without the well-known path).
  • When they differ: fall back to exactly what the user provided (originalBase).

Impact:

Affected file: http-client/src/main/java/org/a2aproject/sdk/client/http/A2ACardResolver.java, resolveUrls() method.

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added theissue type on Sep 25, 2026
  2. self-assigned this
    on Sep 25, 2026
  3. added a commit that references this issue on Sep 25, 2026
    79a0d64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions