From 9038c653290a7d4037165026ff5cb93efc449c52 Mon Sep 17 00:00:00 2001 From: weichen Date: Fri, 18 Sep 2026 03:40:24 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E9=BD=90=20rows.Err()=20?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=EF=BC=88R-2=EF=BC=8C=E5=85=B6=E4=BD=99?= =?UTF-8?q?=E5=8C=85=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 覆盖 kb/storage/projectworkflow/docgov/freedoc 与两个 document CLI。 Co-authored-by: Cursor --- cmd/document-content-reconcile/main.go | 4 ++++ cmd/document-revision-backfill/main.go | 4 ++++ internal/docgov/engine.go | 7 +++++++ internal/freedoc/service.go | 2 +- internal/kb/retrieve.go | 2 +- internal/projectworkflow/store.go | 12 ++++++------ internal/storage/cas.go | 3 +++ internal/storage/cas_assets.go | 2 +- 8 files changed, 27 insertions(+), 9 deletions(-) diff --git a/cmd/document-content-reconcile/main.go b/cmd/document-content-reconcile/main.go index a0af1fb0..7fa1f4e6 100644 --- a/cmd/document-content-reconcile/main.go +++ b/cmd/document-content-reconcile/main.go @@ -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) diff --git a/cmd/document-revision-backfill/main.go b/cmd/document-revision-backfill/main.go index 04117787..6d4c8814 100644 --- a/cmd/document-revision-backfill/main.go +++ b/cmd/document-revision-backfill/main.go @@ -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) diff --git a/internal/docgov/engine.go b/internal/docgov/engine.go index 7363b47b..7e066959 100644 --- a/internal/docgov/engine.go +++ b/internal/docgov/engine.go @@ -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) + } } } diff --git a/internal/freedoc/service.go b/internal/freedoc/service.go index b464e837..16f9eb73 100644 --- a/internal/freedoc/service.go +++ b/internal/freedoc/service.go @@ -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() } // 内存模式 diff --git a/internal/kb/retrieve.go b/internal/kb/retrieve.go index 5f4b1c89..05b23f71 100644 --- a/internal/kb/retrieve.go +++ b/internal/kb/retrieve.go @@ -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 { diff --git a/internal/projectworkflow/store.go b/internal/projectworkflow/store.go index 9e5cf422..4b909857 100644 --- a/internal/projectworkflow/store.go +++ b/internal/projectworkflow/store.go @@ -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() } // ============================================================================= diff --git a/internal/storage/cas.go b/internal/storage/cas.go index 259a7e7d..106d543f 100644 --- a/internal/storage/cas.go +++ b/internal/storage/cas.go @@ -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) diff --git a/internal/storage/cas_assets.go b/internal/storage/cas_assets.go index d08a1ee4..01f1b3d4 100644 --- a/internal/storage/cas_assets.go +++ b/internal/storage/cas_assets.go @@ -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()