fix: 补齐 rows.Err() 检查(R-2,其余包)
覆盖 kb/storage/projectworkflow/docgov/freedoc 与两个 document CLI。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -111,6 +111,10 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
enc, _ := json.MarshalIndent(report, "", " ")
|
||||
if *outPath != "" {
|
||||
_ = os.WriteFile(*outPath, enc, 0o644)
|
||||
|
||||
@@ -116,6 +116,10 @@ func main() {
|
||||
report.Success++
|
||||
report.Items = append(report.Items, it)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
enc, _ := json.MarshalIndent(report, "", " ")
|
||||
if *outPath != "" {
|
||||
_ = os.WriteFile(*outPath, enc, 0o644)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package docgov
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -1022,6 +1023,9 @@ func (e *GovernanceEngine) ListAuditLogs(ctx context.Context, docID string) ([]*
|
||||
e.memAudits[docID] = append(e.memAudits[docID], &a)
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
slog.Warn("docgov_audit_scan_incomplete", "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1058,6 +1062,9 @@ func (e *GovernanceEngine) ListComments(ctx context.Context, docID string) ([]*D
|
||||
e.memComms[docID] = append(e.memComms[docID], &c)
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
slog.Warn("docgov_comments_scan_incomplete", "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -583,7 +583,7 @@ func (s *Service) ListDocuments(ctx context.Context, userID int, projectID int,
|
||||
}
|
||||
results = append(results, sm)
|
||||
}
|
||||
return results, nil
|
||||
return results, rows.Err()
|
||||
}
|
||||
|
||||
// 内存模式
|
||||
|
||||
@@ -266,7 +266,7 @@ func (r *Retriever) searchProjectAsset(ctx context.Context, q string, opts Searc
|
||||
Source: "项目数字资产库",
|
||||
})
|
||||
}
|
||||
return out, nil
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func regStatusFilter(includeRepealed bool) string {
|
||||
|
||||
@@ -201,7 +201,7 @@ func (s *pgStore) ListProjectsForUser(ctx context.Context, userID int64) ([]*Pro
|
||||
}
|
||||
list = append(list, p)
|
||||
}
|
||||
return list, nil
|
||||
return list, rows.Err()
|
||||
}
|
||||
|
||||
func (s *pgStore) ListAllProjects(ctx context.Context) ([]*Project, error) {
|
||||
@@ -258,7 +258,7 @@ func (s *pgStore) ListProjectWorkflows(ctx context.Context, projectID int64) ([]
|
||||
}
|
||||
list = append(list, pw)
|
||||
}
|
||||
return list, nil
|
||||
return list, rows.Err()
|
||||
}
|
||||
|
||||
func (s *pgStore) EnsureProjectWorkflows(ctx context.Context, projectID int64, defaultKeys []string) error {
|
||||
@@ -484,7 +484,7 @@ func (s *pgStore) ListWorkflowRuns(ctx context.Context, projectID int64, workflo
|
||||
}
|
||||
list = append(list, run)
|
||||
}
|
||||
return list, nil
|
||||
return list, rows.Err()
|
||||
}
|
||||
|
||||
func (s *pgStore) RecordLineage(ctx context.Context, lineage *DocumentLineage) error {
|
||||
@@ -532,7 +532,7 @@ func (s *pgStore) GetLineageForDownstream(ctx context.Context, docID string, ver
|
||||
}
|
||||
list = append(list, l)
|
||||
}
|
||||
return list, nil
|
||||
return list, rows.Err()
|
||||
}
|
||||
|
||||
func (s *pgStore) GetLineagesForUpstream(ctx context.Context, upstreamDocID string) ([]*DocumentLineage, error) {
|
||||
@@ -560,7 +560,7 @@ func (s *pgStore) GetLineagesForUpstream(ctx context.Context, upstreamDocID stri
|
||||
}
|
||||
list = append(list, l)
|
||||
}
|
||||
return list, nil
|
||||
return list, rows.Err()
|
||||
}
|
||||
|
||||
func (s *pgStore) MarkDownstreamStale(ctx context.Context, upstreamDocID string, staleReason string) ([]*DocumentLineage, error) {
|
||||
@@ -590,7 +590,7 @@ func (s *pgStore) MarkDownstreamStale(ctx context.Context, upstreamDocID string,
|
||||
}
|
||||
updated = append(updated, l)
|
||||
}
|
||||
return updated, nil
|
||||
return updated, rows.Err()
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
@@ -447,6 +447,9 @@ func (c *CAS) searchMemoryDB(ctx context.Context, opts MemorySearchOptions) ([]*
|
||||
FinalScore: finalScore,
|
||||
})
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, fmt.Errorf("scan cas chunks failed: %w", err)
|
||||
}
|
||||
|
||||
// 按 FinalScore 降序排列
|
||||
sortChunkHits(hits)
|
||||
|
||||
@@ -31,7 +31,7 @@ func (c *CAS) ListProjectRefs(ctx context.Context, projectID int64) ([]*FileRefe
|
||||
}
|
||||
refs = append(refs, ref)
|
||||
}
|
||||
return refs, nil
|
||||
return refs, rows.Err()
|
||||
}
|
||||
|
||||
c.mu.RLock()
|
||||
|
||||
Reference in New Issue
Block a user