Skip to content

fix(sdk): normalize state manager base URL separators - #860

Open
breken-ai wants to merge 1 commit into
FailproofAI:mainfrom
breken-ai:fix/sdk-base-url-trailing-slash
Open

fix(sdk): normalize state manager base URL separators#860
breken-ai wants to merge 1 commit into
FailproofAI:mainfrom
breken-ai:fix/sdk-base-url-trailing-slash

Conversation

@breken-ai

Copy link
Copy Markdown

Fixes #642.

What goes wrong

StateManager(namespace, state_manager_uri="http://localhost:8000/") builds http://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 from EXOSPHERE_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 stays None rather 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.

  • Before the change: 30 failed, 13 passed (every trailing-slash shape, every helper, both configuration paths).
  • After: 43 passed; full SDK suite 217 passed; ruff check . clean.

Evidence record

Repository / issue:        FailproofAI/runtime #642
Upstream SHA / patch SHA:  2db4b154 / 8550f7c
Issue ownership:           open, unassigned, no linked or competing PR (checked 2026-09-12 21:41 UTC, 37 open PRs)
Reproducer:                uv run pytest tests/test_statemanager_base_uri.py → 30 failed, 13 passed on 2db4b154
Patched:                   same command → 43 passed; uv run pytest → 217 passed; uv run ruff check . → clean
Checks not executed:       loopback HTTP integration under a prefix (no server in this change)

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
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.

SDK will not work on "http://localhost:8000/" because of trailing "/"

1 participant