fix(scripts): HTTP 错误带上响应体
raise_for_status 只给一行 URL,而 Label Studio 把真正原因写在响应体里。 批量导入返回 500 时看不到任何线索,排查只能靠猜。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
744e5fd18a
commit
3c964abaa2
@@ -169,3 +169,11 @@ def test_predictions_endpoint_is_not_paginated():
|
||||
methods = [method for method, _, _ in session.requests]
|
||||
assert methods == ["GET", "DELETE", "DELETE"] # 只列一次,删两条
|
||||
assert session.requests[1][1] == "http://ls/api/predictions/1/"
|
||||
|
||||
|
||||
def test_http_errors_include_the_response_body():
|
||||
"""Label Studio 把真正原因写在响应体里,只抛 URL 没法排查。"""
|
||||
session = _TokenSession(statuses=[500], payload={"detail": "boom"})
|
||||
client = _client(session)
|
||||
with pytest.raises(RuntimeError, match="HTTP 500.*boom"):
|
||||
client.request("POST", "/api/projects/39/import/predictions", json=[])
|
||||
|
||||
Reference in New Issue
Block a user