Repository navigation
node: keep the interface path in the regenerated A2A agent card - #677
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the A2A service to preserve sub-paths of agent interfaces (such as /invoke or /rest) below the mesh path when regenerating agent cards, rather than pointing all interfaces to the bare service root. It introduces response modification in the reverse proxy to relativize the URLs in the agent card, along with validation to prevent directory traversal or external redirects. Unit and integration tests, as well as documentation, have been updated accordingly. Feedback focuses on aligning with the repository style guide: specifically, logging a warning when skipping relativization due to compressed responses (Section 6) and ensuring test assertions explicitly print both observed and expected values (Section 3).
| if len(card.SupportedInterfaces) != 1 || card.SupportedInterfaces[0].URL != meshBase+"/invoke" { | ||
| t.Errorf("interfaces not regenerated / gRPC not dropped: %+v", card.SupportedInterfaces) | ||
| } |
There was a problem hiding this comment.
3. Test coverage must follow the pyramid
The assertion message does not state both the observed and the expected value, which violates the repository style guide (Section 3, Rule 8). Please update the assertion to explicitly print both.
| if len(card.SupportedInterfaces) != 1 || card.SupportedInterfaces[0].URL != meshBase+"/invoke" { | |
| t.Errorf("interfaces not regenerated / gRPC not dropped: %+v", card.SupportedInterfaces) | |
| } | |
| if len(card.SupportedInterfaces) != 1 || card.SupportedInterfaces[0].URL != meshBase+"/invoke" { | |
| t.Errorf("interfaces not regenerated / gRPC not dropped: got %+v, want exactly one interface with URL %q", card.SupportedInterfaces, meshBase+"/invoke") | |
| } |
References
- Section 3, Rule 8: Tests are plain Go on the standard testing package... Flag assertion messages that do not state both the observed and the expected value. (link)
|
need to rebase also we like to have good visibility on errors #677 (comment) otherwise in a p2p network is hard to debug problems, that comment from the bot reviewer is legit |
f921673 to
7390b71
Compare
|
Rebased on main. A compressed card is now logged ( |
7390b71 to
b9857a2
Compare
|
I just realized the e2e test added previously with streaming was not exercising the datapath https://github.com/google/agentmesh/compare/7390b7164c778df87855fdf4b423faeadf54472b..b9857a221d98f2e230d6174acc0980837d8d725a |
|
sdk/js |
rewriteAgentCard (JS) and rewrite_agent_card (Python) pointed every JSONRPC and HTTP+JSON interface at the bare service root, so an agent whose endpoint is "/invoke" or whose HTTP+JSON binding lives under "/rest" was unreachable through an SDK member, the same bug the node fix addresses. Both SDKs now resolve the relative reference the provider's node writes under the mesh URL, with the node's rules: anything absolute, rooted, with a scheme, a host or a dot segment maps to the service root. The JS and Python tests carry the cases of TestMeshInterfaceURLStaysInService and TestA2AServiceCardKeepsInterfacePaths.
|
Added the SDK side in the same PR: |
|
Thanks |
sure, remember to add an integration or e2e test that validates the full code path and datapath ... integration test are faster ... |
Fixes #673.
The caller's node set every HTTP interface in the regenerated card to the service root, so an agent that serves JSON-RPC at
/invoke(the a2a-go samples) or HTTP+JSON under/a2a/restwas unreachable through the mesh.A2AServicerewrites each JSONRPC or HTTP+JSON interface undertarget_urlto a relative reference (invoke,a2a/rest, or"") when it relays the card.meshInterfaceURLresolves that reference under the mesh URL. An absolute URL, a URL outside the target path, or a reference with a dot segment, a leading/, a scheme or a host maps to the service root as before, so mixed node versions behave as today and a provider cannot point the caller at another path on the caller's node.Tests: new unit tests in
a2a_service_test.go;TestA2ACUJnow serves the agent at/invoke(404 on main, passes with the change). Through two nodes the A2A TCK (263b9cf, Python reference SUT) goes from 77 to 122 passed.go test -race ./...and the integration suite pass on Linux; golangci-lint reports 0 issues.The Python and JS SDKs rewrite the card the same way; they are not changed here.