Repository navigation
fix(protocol): strip trailing slashes from base_url in protocol client - #520
earakely-scale merged 5 commits into
Conversation
|
Added test_invoke_extension_ensures_leading_slash_on_relative_endpoint asserting that endpoints lacking a leading slash are properly formatted with exactly one slash. |
andrewpark-scaleai
left a comment
There was a problem hiding this comment.
LGTM. I ran test_client.py (45 passed), and 3 of the new tests fail against main, so they cover the bug.
Two optional follow-ups:
- A few other places still join
base_urlby concatenation:env_gateway_provider.py:1674,1678,env_provider.py:125, andwebsite/conformance.py:90. A trailing slash still produces//there. It might be worth normalizingbase_urlonce where it enters, or noting the remaining gap in the description. - If a card leaves out
endpoint,invoke_extensionnow raisesAttributeErroronNone.startswith. Previously it builthttp://hostNone. A clearValueErrorwould be friendlier.
|
Added an explicit unit test verifying that invoke_extension raises ValueError when an extension card omits endpoint. Noted the other concatenation locations (env_gateway_provider.py, env_provider.py, website/conformance.py) for a separate follow-up normalization pass. |
Every card the protocol's server writes gives an endpoint with its leading slash, so a card without one is malformed rather than something the client should mend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
What I pushed (52e1866, a merge of
Checked:
|
|
Want your agent to iterate on Greptile's feedback? Start a greploop in Cursor and it will work through the open comments and keep going until this PR reviews clean. |
What and why
The protocol client built three of its request URLs by appending a path to
base_url: the data plane's JSON-RPC (reset_data,add_data,get_data),get_card, andinvoke_extension. A base URL with a trailing slash, as one typed by hand often has (http://host:8000/), gave//agentenv,//.well-known/agent-env.jsonand//agentenv/ext/..., which a server's routes don't match.This strips trailing slashes from
base_urlin those three places, as the module already does inauthorized,granted_headers,get_interface_manifest,ChildEnv.base_urlandfetch_interface. No caller in this repository passes such a URL today; this is for callers of the client SDK.An extension's
endpointis used as the card gives it. Every card the protocol's server writes gives it with its leading slash, so one without is a malformed card, not something the client mends.How it was tested
test_rpc_and_card_strip_trailing_slashes_from_base_urlandtest_invoke_extension_strips_trailing_slashes_from_base_urlfail againstmainand pass with this change.test_invoke_extension_missing_endpoint_raises_value_errorcovers the existing error for a card with no endpoint.packages/agentenv-protocol/tests: 1354 passed, 2 skipped. Ruff is clean.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge.Summary
The client strips trailing slashes from
base_urlbefore building data, card, and extension request URLs.Reviews (9) · Last reviewed commit: "Merge main; drop the leading slash added..." · Reviewed by Greptile