fix(sdk): normalize state manager base URL separators - #860
Open
breken-ai wants to merge 1 commit into
Open
Conversation
A `state_manager_uri` ending in "/" ("http://localhost:8000/") produced endpoints with a
doubled separator ("http://localhost:8000//v0/namespace/..."), which some servers and
proxies reject (FailproofAI#642). The three endpoint helpers interpolate `{base}/{version}/...`, and
nothing normalised the base after it was resolved.
Normalise once, after `_set_config_from_env()` resolves the final value, by stripping
trailing separators only. Scheme, authority, port and a deployment prefix such as `/api`
are preserved; a missing URI stays `None` (rejecting it eagerly is a separate contract
change). Explicit and environment-sourced configuration are normalised the same way.
Regression: tests/test_statemanager_base_uri.py — seven base shapes (with/without slash,
prefix, IPv6, repeated slashes) × three endpoint helpers × explicit/environment
configuration, plus the missing-URI case. 30 of 43 fail before the change, all pass after.
Fixes FailproofAI#642
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.
Fixes #642.
What goes wrong
StateManager(namespace, state_manager_uri="http://localhost:8000/")buildshttp://localhost:8000//v0/namespace/<ns>/graph/<g>: the three endpoint helpers interpolate{base}/{version}/…and nothing normalises the base, so a URI with a trailing slash, from the constructor or fromEXOSPHERE_STATE_MANAGER_URI, gets a doubled separator that some servers and proxies reject.The change
One normalisation in
_set_config_from_env(), after the environment fallback, so explicit and environment configuration behave the same: trailing separators are stripped from the resolved string. Scheme, authority, port and a deployment prefix (https://example.test/api/→…/api) are preserved; a missing URI staysNonerather than becoming a valid-looking string. Nothing else about URL handling changes. The README's parameter note says the slash is accepted.Tests
python-sdk/tests/test_statemanager_base_uri.py: seven base shapes (with and without a trailing slash,/api/prefix, IPv6 authority, repeated slashes) × the three endpoint helpers × explicit and environment configuration, plus the missing-URI case.ruff check .clean.Evidence record