fix(client): resolve REST endpoint from discovery profile#90
Open
ynachiket wants to merge 1 commit intoUniversal-Commerce-Protocol:mainfrom
Open
fix(client): resolve REST endpoint from discovery profile#90ynachiket wants to merge 1 commit intoUniversal-Commerce-Protocol:mainfrom
ynachiket wants to merge 1 commit intoUniversal-Commerce-Protocol:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
528ebe7 to
8e983bf
Compare
The happy path client was ignoring the `endpoint` field from the `/.well-known/ucp` discovery response and instead hardcoding all API paths against the initial `--server_url`. Per the UCP spec (Endpoint Resolution section): > "The endpoint field provides the base URL for API calls. OpenAPI > paths are appended to this endpoint to form the complete URL." This works by coincidence when the merchant serves the API at its domain root (e.g. `http://localhost:8182`), but breaks when the merchant mounts the API under a path prefix (e.g. `https://merchant.com/buy/v1`). In that case the client would hit `https://merchant.com/checkout-sessions` instead of the correct `https://merchant.com/buy/v1/checkout-sessions`, resulting in 403/404. This commit: - Adds endpoint_resolution.py with the resolve_rest_endpoint() helper - Uses the resolved endpoint to recreate the httpx client base_url - Updates exported curl URLs to reflect the resolved endpoint - Falls back to --server_url if no endpoint is found in discovery - Adds 9 unit tests covering path-prefixed, root-level, multi-transport, and missing/empty endpoint scenarios Made-with: Cursor
8e983bf to
24ca504
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The happy path client was ignoring the
endpointfield from the/.well-known/ucpdiscovery response and instead hardcoding all API paths against the initial--server_url.Per the UCP spec (Endpoint Resolution section):
This works by coincidence when the merchant serves the API at its domain root (e.g.
http://localhost:8182), but breaks when the merchant mounts the API under a path prefix (e.g.https://merchant.com/buy/v1). In that case the client would hithttps://merchant.com/checkout-sessionsinstead of the correcthttps://merchant.com/buy/v1/checkout-sessions, resulting in 403/404.This commit: