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:
@@ -112,3 +112,51 @@ func TestScheduledReconciliationClaimsOncePerDayAfterFailure(t *testing.T) {
|
||||
t.Fatalf("next-day claim claimed=%t err=%v", claimed, err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestLoadReconciliationActionViewJoinsWithoutAmbiguity freezes the action-view
|
||||
// SQL: it joins reconciliation_runs and test_publications, both of which also
|
||||
// own id/title/path, so an unqualified column list fails with
|
||||
// `column reference "id" is ambiguous` and every writeback/requeue/remove
|
||||
// answered 500 instead of touching the finding.
|
||||
func TestLoadReconciliationActionViewJoinsWithoutAmbiguity(t *testing.T) {
|
||||
url := isolatedIntegrationDatabaseURL(t, os.Getenv("TEST_DATABASE_URL"))
|
||||
if url == "" {
|
||||
t.Skip("TEST_DATABASE_URL is not set")
|
||||
}
|
||||
ctx := context.Background()
|
||||
pool, err := pgxpool.New(ctx, url)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer pool.Close()
|
||||
if err := ApplyMigrations(ctx, pool); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
started := time.Date(2026, 12, 1, 2, 0, 0, 0, time.UTC)
|
||||
exec := func(query string, args ...any) {
|
||||
t.Helper()
|
||||
if _, err := pool.Exec(ctx, query, args...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
exec(`INSERT INTO source_connections(id,source_type,name,enabled) VALUES('conn-action','dingtalk','处置视图用例',TRUE)`)
|
||||
exec(`INSERT INTO source_items(id,source_connection_id,stable_external_id,canonical_uri_hash,title,item_type,policy_state)
|
||||
VALUES('si-action','conn-action','action.md',repeat('d',64),'处置视图','file','blocked')`)
|
||||
exec(`INSERT INTO source_item_versions(id,source_item_id,revision,content_state) VALUES('sv-action','si-action','r1','verified')`)
|
||||
exec(`INSERT INTO test_publications(id,source_item_version_id,test_kb_id,knowledge_id,ingest_state,processing_state,retrieval_state)
|
||||
VALUES('pub-action','sv-action','kb-action','doc-action','uploaded','completed','unpublished')`)
|
||||
exec(`INSERT INTO reconciliation_runs(id,test_kb_id,state,trigger,started_at,counts,created_at)
|
||||
VALUES('run-action','kb-action','succeeded','manual',$1,'{}'::jsonb,$1)`, started)
|
||||
exec(`INSERT INTO reconciliation_findings(id,run_id,finding_type,publication_id,knowledge_id,title,ledger_state,suggested_action)
|
||||
VALUES('finding-action','run-action','R6','pub-action','doc-action','处置视图','completed','enter_removal')`)
|
||||
|
||||
store := NewStore(pool)
|
||||
view, err := store.LoadReconciliationActionView(ctx, "finding-action")
|
||||
if err != nil {
|
||||
t.Fatalf("action view error = %v (ambiguous columns surface here)", err)
|
||||
}
|
||||
if view.TestKBID != "kb-action" || !view.CurrentExists || view.CurrentProcessingState != "completed" ||
|
||||
view.CurrentKnowledgeID != "doc-action" || view.Finding.ID != "finding-action" {
|
||||
t.Fatalf("action view = %#v", view)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user