Describe the Bug
When using the Custom translation provider with a local OpenAI-compatible endpoint (LM Studio), the plugin consistently fails to parse the standard chat completion response. Even though the backend successfully returns a valid JSON containing the translated text, the OBS log instantly throws a type mismatch exception.
Environment
- **OBS Studio Version:32.1.2
- **Plugin Version:obs-localvocal (latest build)
- LLM Backend: LM Studio (Running
sakura-galtransl-7b-v3.7)
- API Endpoint:
http://127.0.0.1:1234/v1/chat/completions
- Response JSON Path Specified:
choices.0.message.content
Exact Evidence & Log Synchronization
Here is the exact verified response generated by the local LLM backend (LM Studio Developer Logs):
{
"id": "chatcmpl-v4qesz0fj3dkzkfjj2pwk",
"object": "chat.completion",
"created": 1779590135,
"model": "sakura-galtransl-7b-v3.7",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "现在就先保密吧",
"reasoning_content": "",
"tool_calls": []
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 6,
"total_tokens": 129,
"completion_tokens_details": {
"reasoning_tokens": 0
}
},
"stats": {},
"system_fingerprint": "sakura-galtransl-7b-v3.7"
}
Immediately after this payload is sent back to the plugin, the OBS Log outputs the following parsing error:
10:36:24.016: [obs-localvocal] Translation error: JSON parsing error: JSON parsing error: [json.exception.type_error.302] type must be string, but is null
Technical Root Cause
The [json.exception.type_error.302] originates from the modern C++ JSON library (nlohmann/json). This specific error indicates that the plugin's C++ parsing logic expected to encounter a primitive string value at the targeted layer, but evaluated it as a null value instead.
Since the raw payload undeniably contains a valid string "现在就先保密吧" under choices[0].message.content, the type error proves that the plugin's internal path-walking evaluator fails to properly navigate multi-layered objects or array indices (choices.0), causing the pointer to drop out into null and crash the translation rendering pipeline.
Expected Behavior
The plugin should seamlessly parse standard nested OpenAI JSON structures when users supply a valid JSON Path like choices.0.message.content.
Describe the Bug
When using the
Customtranslation provider with a local OpenAI-compatible endpoint (LM Studio), the plugin consistently fails to parse the standard chat completion response. Even though the backend successfully returns a valid JSON containing the translated text, the OBS log instantly throws a type mismatch exception.Environment
sakura-galtransl-7b-v3.7)http://127.0.0.1:1234/v1/chat/completionschoices.0.message.contentExact Evidence & Log Synchronization
Here is the exact verified response generated by the local LLM backend (
LM StudioDeveloper Logs):{ "id": "chatcmpl-v4qesz0fj3dkzkfjj2pwk", "object": "chat.completion", "created": 1779590135, "model": "sakura-galtransl-7b-v3.7", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "现在就先保密吧", "reasoning_content": "", "tool_calls": [] }, "logprobs": null, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 123, "completion_tokens": 6, "total_tokens": 129, "completion_tokens_details": { "reasoning_tokens": 0 } }, "stats": {}, "system_fingerprint": "sakura-galtransl-7b-v3.7" }Immediately after this payload is sent back to the plugin, the OBS Log outputs the following parsing error:
Technical Root Cause
The
[json.exception.type_error.302]originates from the modern C++ JSON library (nlohmann/json). This specific error indicates that the plugin's C++ parsing logic expected to encounter a primitive string value at the targeted layer, but evaluated it as anullvalue instead.Since the raw payload undeniably contains a valid string
"现在就先保密吧"underchoices[0].message.content, the type error proves that the plugin's internal path-walking evaluator fails to properly navigate multi-layered objects or array indices (choices.0), causing the pointer to drop out intonulland crash the translation rendering pipeline.Expected Behavior
The plugin should seamlessly parse standard nested OpenAI JSON structures when users supply a valid JSON Path like
choices.0.message.content.