Skip to content

[Platform][Generic] Encode request body with JSON_UNESCAPED_SLASHES#2087

Open
chr-hertel wants to merge 1 commit into
symfony:mainfrom
chr-hertel:fix_ai_1973
Open

[Platform][Generic] Encode request body with JSON_UNESCAPED_SLASHES#2087
chr-hertel wants to merge 1 commit into
symfony:mainfrom
chr-hertel:fix_ai_1973

Conversation

@chr-hertel

Copy link
Copy Markdown
Member
Q A
Bug fix? yes
New feature? no
Docs? no
Issues Fix #1973
License MIT

The Generic completions and embeddings ModelClient classes passed the request payload via the HttpClient json option. Symfony's HttpClientTrait::jsonEncode() encodes without JSON_UNESCAPED_SLASHES, so a namespaced model name like qwen/qwen3.5-4b was sent on the wire as "model":"qwen\/qwen3.5-4b".

That is valid JSON, but several OpenAI-compatible backends (observed with vLLM and LM Studio) do a raw string comparison of the model key during routing and fail to match the escaped form, returning a "model not found" error for any namespaced model name containing /.

Both clients now encode the body explicitly with JSON_UNESCAPED_SLASHES and pass it as body. The remaining flags mirror HttpClientTrait::jsonEncode() so the only intentional deviation is the unescaped slashes.

Tests added to both ModelClientTest classes asserting forward slashes in model names are not escaped.

The Generic completions and embeddings clients passed the payload via the
HttpClient "json" option, whose encoder escapes forward slashes. A namespaced
model name like "qwen/qwen3.5-4b" was sent as "qwen\/qwen3.5-4b", which some
OpenAI-compatible backends (vLLM, LM Studio) fail to match. Encode the body
explicitly with JSON_UNESCAPED_SLASHES while mirroring the remaining flags from
Symfony's HttpClientTrait::jsonEncode().
@chr-hertel chr-hertel requested a review from OskarStark as a code owner May 15, 2026 08:10
@carsonbot carsonbot added Bug Something isn't working Platform Issues & PRs about the AI Platform component Status: Needs Review labels May 15, 2026
@chr-hertel chr-hertel force-pushed the fix_ai_1973 branch 2 times, most recently from f3df4f9 to 1ce65e3 Compare May 15, 2026 09:12
@chr-hertel

Copy link
Copy Markdown
Member Author

Not sure about the impact here ... 🤔

@OskarStark OskarStark changed the title [Platform][Generic] Encode request body with JSON_UNESCAPED_SLASHES [Platform][Generic] Encode request body with JSON_UNESCAPED_SLASHES May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Platform Issues & PRs about the AI Platform component Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Platform][Generic] Forward slashes in model names are JSON-escaped, breaking some OpenAI-compatible backends

2 participants