docs(W18): D2.4 索引口径更正为 AUTOINDEX(v1.6)+ D2.9 手动对话测试用例成文 + 空白消息 500 修复
- D2.4 v1.3 -> v1.6:索引统一 AUTOINDEX(设计初稿 HNSW/IVF_FLAT 未落地,实库直查为据) 更正 9 处 + 新增 §4.1 索引口径落地注;语料 628 -> 675 块并补 fin_basic_collection 说明 (三集合仍是唯一默认检索面,basic 并入会使 M-1 100% -> 91.3%) - 新增 客服agent/D2.9-客服Agent手动对话测试用例-2026-09-20.md: 46 条金标逐条可问 + 11 条边界 Z 组 + 判分四问 + M-1~M-10 手动汇总 + 真 HTTP 核验配方 实测登记 3 项缺口:空白消息 500(已修)/ 语料档位口径矛盾(待裁定)/ 重复问句漂移(待裁定) - 修修复:message 纯空白 500 -> 422 AGENT_INPUT_INVALID(入口补判据 + 回归测试) - tools/chat_console.py 提示语去掉已下线产品名(季季盈) - 落档:D1.1 §27(60 -> 61 份 / 客服agent 8 -> 9 份 / 注入校验 56 -> 57)、D2.1 v6.33、D1.6 §4.46 - 门禁:check_authoritative_docs 通过、_consistency.py GATE PASS、pytest 1915 passed / 0 failed
This commit is contained in:
@@ -44,6 +44,30 @@ def test_missing_body_fields_use_unified_envelope() -> None:
|
||||
assert body["meta"] == {"trace_id": "val-trace"}
|
||||
|
||||
|
||||
def test_blank_message_is_rejected_at_the_gateway() -> None:
|
||||
"""纯空白消息 → 422 信封,**不是 500**。
|
||||
|
||||
回归自实测缺口:`min_length=1` 挡不住 `" "`(长度 3),它会穿透入口、被领域层
|
||||
`AgentRequest` 的 `message must not be blank` 拒掉,而领域层的 `ValidationError`
|
||||
不属于请求校验异常 ⇒ 客户端拿到的是 500 Internal Server Error(无 code、无 trace)。
|
||||
"""
|
||||
with _authenticated_client() as client:
|
||||
response = client.post(
|
||||
AGENT_RUNS,
|
||||
json={
|
||||
"agent_type": "customer_service", "message": " ",
|
||||
"session_id": "blank-msg-session", "idempotency_key": "k" * 32,
|
||||
},
|
||||
headers={"X-Trace-ID": "blank-trace"},
|
||||
)
|
||||
|
||||
assert response.status_code == 422, f"空白消息应被入口拦下,实际 {response.status_code}"
|
||||
body = response.json()
|
||||
assert set(body) == {"error", "meta"}
|
||||
assert body["error"]["code"] == "AGENT_INPUT_INVALID"
|
||||
assert "body.message" in {item["field"] for item in body["error"]["field_errors"]}
|
||||
|
||||
|
||||
def test_validation_handler_does_not_hijack_authentication() -> None:
|
||||
"""未带令牌 + 参数也不合法:必须仍是 401,参数校验不得掩盖鉴权失败。"""
|
||||
with TestClient(create_app()) as client:
|
||||
|
||||
Reference in New Issue
Block a user