QA 在候选上实测出两条: - P0 处置接口 500:LoadReconciliationActionView 的 SELECT 用了未限定的 reconciliationFindingColumns,而语句 JOIN 了 reconciliation_runs 与 test_publications(两者也有 id/title/path/source),PostgreSQL 直接报 column reference "id" is ambiguous,writeback/requeue/remove 全部 500。 改为按别名限定列(qualifiedFindingColumns),补真库集成用例。 - R-102 契约偏差:空的 document_id 被多段路由规范化成 307、含未编码斜杠的 id 落到 404,契约要求 400。补子树兜底路由,并在鉴权之后加 guard 把 // 路径拦成 400 (未登录仍是 401),补接口用例。
This commit is contained in:
@@ -855,15 +855,32 @@ func NewHandler(config Config) (http.Handler, error) {
|
||||
mux.HandleFunc("POST /api/v1/job-failures/{id}/requeue", func(w http.ResponseWriter, r *http.Request) {
|
||||
requeueJobFailure(w, r, config)
|
||||
})
|
||||
// 契约要求非法 document_id 返回 400:空段(documents//progress)会被 ServeMux
|
||||
// 规范化成 307,含未编码斜杠的 id 会落到 404。这里在路由前判定形状,且不新增
|
||||
// 端点(契约已冻结);放在鉴权之后,未登录仍是 401,保持 401 → 400 的顺序。
|
||||
guard := func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
const prefix = "/api/v1/reconciliation/documents/"
|
||||
if strings.HasPrefix(r.URL.Path, prefix) {
|
||||
rest := strings.TrimPrefix(r.URL.Path, prefix)
|
||||
segments := strings.Split(rest, "/")
|
||||
if strings.Contains(r.URL.Path, "//") || len(segments) != 2 || segments[0] == "" || segments[1] != "progress" {
|
||||
writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid document id"})
|
||||
return
|
||||
}
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
if config.Auth != nil {
|
||||
if config.Auth.Store == nil {
|
||||
return nil, errors.New("auth configuration requires a store")
|
||||
}
|
||||
config.authRoutes(mux)
|
||||
config.userRoutes(mux)
|
||||
return masterNoStore(config.Auth.authenticate(mux)), nil
|
||||
return masterNoStore(config.Auth.authenticate(guard(mux))), nil
|
||||
}
|
||||
return masterNoStore(mux), nil
|
||||
return masterNoStore(guard(mux)), nil
|
||||
}
|
||||
|
||||
type createJobRequest struct {
|
||||
|
||||
Reference in New Issue
Block a user