- 页面 9 个出口统一走 reconciliationMessages:四个内部码不再进入 DOM,未知码回退中文;批次行/阶段码同样翻译。 - 绑定页加载与点击前读 /api/v1/kb-bindings 预检:测试环境未配置当场提示且不发 POST;未启用优先于绑定缺失。 - 运行时读按上游 401/403 与连接失败拆成 runtime_key_forbidden / runtime_unreachable,保留 404 与未配置语义。 - EnvironmentLabel 与前端环境标签改「测试/生产知识库」,不再出现 090。 - 验:make verify 17 项全绿;go test 三包、web 656 用例、typecheck 通过。
This commit is contained in:
@@ -46,6 +46,10 @@ func writeReconciliationError(w http.ResponseWriter, err error) {
|
||||
writeJSON(w, http.StatusNotFound, map[string]string{"error": "reconciliation record not found"})
|
||||
case errors.Is(err, reconciliation.ErrActionConflict), errors.Is(err, reconciliation.ErrActionNotAllowed):
|
||||
writeJSON(w, http.StatusConflict, map[string]string{"error": "reconciliation_state_changed", "code": "reconciliation_state_changed"})
|
||||
case errors.Is(err, reconciliation.ErrRuntimeForbidden):
|
||||
writeJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "runtime_key_forbidden", "code": "runtime_key_forbidden"})
|
||||
case errors.Is(err, reconciliation.ErrRuntimeUnreachable):
|
||||
writeJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "runtime_unreachable", "code": "runtime_unreachable"})
|
||||
case errors.Is(err, reconciliation.ErrRuntimeUnavailable):
|
||||
writeJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "runtime_read_unavailable", "code": "runtime_read_unavailable"})
|
||||
case errors.Is(err, reconciliation.ErrRemoteFailed):
|
||||
|
||||
@@ -144,3 +144,25 @@ func TestReconciliationProgressRejectsMalformedDocumentIDWith400(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReconciliationProgressClassifiesRuntimeFailures(t *testing.T) {
|
||||
cases := []struct {
|
||||
err error
|
||||
code string
|
||||
}{
|
||||
{reconciliation.ErrRuntimeForbidden, "runtime_key_forbidden"},
|
||||
{reconciliation.ErrRuntimeUnreachable, "runtime_unreachable"},
|
||||
{reconciliation.ErrRuntimeUnavailable, "runtime_read_unavailable"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
handler, err := NewHandler(Config{Store: &fakeJobStore{}, Reconciliation: &reconciliationServiceStub{err: tc.err}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(recorder, reconciliationRequest(http.MethodGet, "/api/v1/reconciliation/documents/doc-1/progress", roleViewer, ""))
|
||||
if recorder.Code != http.StatusServiceUnavailable || !strings.Contains(recorder.Body.String(), tc.code) {
|
||||
t.Fatalf("%v = %d %s, want 503 %s", tc.err, recorder.Code, recorder.Body.String(), tc.code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user