Huanshere / Huanshere/VideoLingo

[Bug] GPT request failed: Error code: 400 - Cannot read properties of null (reading 'type')

Open Beginner friendly
#545 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
18.5k
Forks
2k
Avg merge
7h 41m
Merged PRs (30d)
12

Description

运行环境:

OS: Debian GNU/Linux forky/sid (forky) x86_64
Kernel: Linux 6.19.10+deb14-amd64
CPU: Intel(R) Xeon(R) E5-2680 v4 (28) @ 3.30 GHz
GPU: AMD Radeon RX 590 GME [Discrete]

问题描述:

使用videoLingo调用LM-Studio-0.4.9-1-x64本地运行gemma-4-e4b-it的api服务时出现

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 5/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 6/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 1/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 1/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 2/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 3/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 4/5

GPT request failed: Error code: 400 - {'error': "Cannot read properties of null (reading 'type')"}, retry: 5/5 

lm_studio的日志:
2026-04-04 18:37:33 [DEBUG]

Received request: POST to /v1/chat/completions with body  {

"messages": [

{

"role": "user",

"content": "This is a test, response 'message':'success' in json format."

}

],

"model": "gemma-4-e4b-it",

"response_format": null

} 

发现lm_studio不能处理response_format为null的请求。
core/utils/ask_gpt.py中第60行
response_format = {"type": "json_object"} if resp_type == "json" and load_key("api.llm_support_json") else None
不满足条件时response_format就会变成null,导致400错误。

可能的解决办法:

动态构建 params 字典,不满足条件时,不应包含response_format字段。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in core/utils/ask_gpt.py around line 60 and inspect how the request parameters are assembled. Reproduce the request with LM Studio using the reported configuration, then verify that requests sent without JSON response support omit response_format rather than sending it as null.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.