Skip to content

fix(protocol): strip trailing slashes from base_url in protocol client - #520

Merged
earakely-scale merged 5 commits into
scaleapi:mainfrom
saiyam-jain-dev:fix/protocol-client-trailing-slash
Nov 9, 2026
Merged

earakely-scale merged 5 commits into
scaleapi:mainfrom
saiyam-jain-dev:fix/protocol-client-trailing-slash

Conversation

@saiyam-jain-dev

@saiyam-jain-dev saiyam-jain-dev commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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, and invoke_extension. A base URL with a trailing slash, as one typed by hand often has (http://host:8000/), gave //agentenv, //.well-known/agent-env.json and //agentenv/ext/..., which a server's routes don't match.

This strips trailing slashes from base_url in those three places, as the module already does in authorized, granted_headers, get_interface_manifest, ChildEnv.base_url and fetch_interface. No caller in this repository passes such a URL today; this is for callers of the client SDK.

An extension's endpoint is 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_url and test_invoke_extension_strips_trailing_slashes_from_base_url fail against main and pass with this change. test_invoke_extension_missing_endpoint_raises_value_error covers the existing error for a card with no endpoint.
  • The protocol suite, packages/agentenv-protocol/tests: 1354 passed, 2 skipped. Ruff is clean.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

The client strips trailing slashes from base_url before building data, card, and extension request URLs.

  • Protocol requests join their paths to a base URL without trailing slashes.

Reviews (9) · Last reviewed commit: "Merge main; drop the leading slash added..." · Reviewed by Greptile

@saiyam-jain-dev
saiyam-jain-dev requested a review from a team as a code owner November 6, 2026 22:23
@saiyam-jain-dev

Copy link
Copy Markdown
Contributor Author

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 andrewpark-scaleai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_url by concatenation: env_gateway_provider.py:1674,1678, env_provider.py:125, and website/conformance.py:90. A trailing slash still produces // there. It might be worth normalizing base_url once where it enters, or noting the remaining gap in the description.
  • If a card leaves out endpoint, invoke_extension now raises AttributeError on None.startswith. Previously it built http://hostNone. A clear ValueError would be friendlier.

@saiyam-jain-dev

Copy link
Copy Markdown
Contributor Author

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.

earakely-scale and others added 2 commits November 8, 2026 17:39
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>
@earakely-scale

Copy link
Copy Markdown
Collaborator

What I pushed (52e1866, a merge of main with no force-push):

  • The leading slash added to extension endpoints is gone, with its test. No card in this repository gives an endpoint without one: the protocol's server always writes /agentenv/ext/..., and the README shows /ext/staging. A card without one is malformed, and mending it quietly would hide that. AGENTS.md also asks for no defensive code for a case no caller produces.
  • Kept: the trailing-slash fix in all three places, its two tests, and the missing-endpoint test.

Checked:

  • Both trailing-slash tests fail against main and pass with the change. The protocol suite passes: 1354 passed, 2 skipped.
  • No caller in core passes a trailing-slash base to the client today; the website routing path passes <gateway>/svc/<name>. So this is for SDK callers, as the description now says.
  • The other plain-concatenation sites noted in review (env_provider.py, env_gateway_provider.py, website conformance) take base URLs from sandbox providers, which never end in /, so they stay out of this PR.

@greptile-apps

greptile-apps Bot commented Nov 9, 2026

Copy link
Copy Markdown

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.

@earakely-scale
earakely-scale merged commit c2e91b7 into scaleapi:main Nov 9, 2026
37 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants