Skip to content

fix(vectorizer): skip CSV files without matching csv-config instead of aborting the cycle#61

Merged
rluisr merged 1 commit intomainfrom
fix/skip-unmatched-csv-files
Apr 21, 2026
Merged

fix(vectorizer): skip CSV files without matching csv-config instead of aborting the cycle#61
rluisr merged 1 commit intomainfrom
fix/skip-unmatched-csv-files

Conversation

@rluisr
Copy link
Copy Markdown
Contributor

@rluisr rluisr commented Apr 21, 2026

概要

follow モードでの vectorize サイクルが、CSV ファイル 1 件の設定ミスで毎回サイクル全体が失敗し、新規/更新ファイル(Markdown 含む)が一切インデックスされない問題を修正。

原因

#59 (18aefdf) で導入された VectorizerService.expandCSVFiles は、csvReader.Read{File,Content} が返す「no pattern matches」エラーをそのまま上流に伝播させるため、バッチ全体が即時失敗する fail-fast になっていた。

変更点

  • internal/ingestion/csv/errors.go に sentinel ErrNoCSVConfig を追加。
  • reader.go の 4 箇所 (ReadFile / ReadContent / GetDetectedColumns / GetDetectedColumnsFromContent) の該当エラーを fmt.Errorf(\"%w: %s\", ErrNoCSVConfig, path) に書き換え。エラーメッセージはファイルパスを保持。
  • service.goexpandCSVFileserrors.Is(err, csv.ErrNoCSVConfig) の分岐を追加: 該当ファイルは log.Printf(\"Warning: Skipping CSV file %s: ...\") で skip し、サイクルは継続。他のエラー (IO / parse / invalid header 等) はこれまで通り propagate。skip 件数はサマリとして 1 行出力。
  • テスト:
    • reader_test.goTestReader_ReadFile_NoMatchingPatternerrors.Is(err, ErrNoCSVConfig) ベースに更新し、file path がエラーに含まれることもアサート。
    • expand_csv_test.go を新設し、(a) unmatched CSV が skip されマッチ分だけ expand される、(b) 非 ErrNoCSVConfig エラーは伝播、(c) 全件 unmatched でも markdown だけは通過、の 3 ケースを追加。

非目的

  • 前回 PR の embedding 除外 fix (f0b8154 / f22c0ec / f16c55d) は本問題とは無関係(検索レスポンス側の話)。

検証

  • `make lint`: 0 issues
  • `go test $(go list ./... | grep -v '/tests/') -timeout 120s`: all pass (vectorizer パッケージで warning ログ出力も確認)
  • TestExpandCSVFiles_SkipsFilesWithoutMatchingConfig / _PropagatesNonConfigErrors / _AllUnmatchedStillSucceeds の 3 本追加、TestReader_ReadFile_NoMatchingPattern 更新、全て pass

…f aborting the cycle

A single CSV file in the scan set that does not match any pattern in
csv-config.yaml used to abort the entire vectorization cycle, preventing
all other files (including brand new / modified markdown) from being
indexed. In follow mode on production this meant every 5-minute cycle
failed and no new documents were vectorized.

Introduce a sentinel error `csv.ErrNoCSVConfig` and teach
`VectorizerService.expandCSVFiles` to recognise it: such files are now
logged as a warning and skipped while the rest of the batch continues.
All other CSV errors (parse failures, invalid headers, IO errors, etc.)
still propagate unchanged.

- Add csv.ErrNoCSVConfig sentinel and wrap the four "no pattern matches"
  call sites in internal/ingestion/csv/reader.go with it.
- Update expandCSVFiles to errors.Is check, warn+skip, and emit a
  summary line when any files were skipped.
- Update the existing csv reader test to assert on ErrNoCSVConfig via
  errors.Is, and add expand_csv_test.go covering skip behaviour, error
  propagation for non-config errors, and the all-unmatched edge case.
@rluisr rluisr merged commit 8039a5e into main Apr 21, 2026
15 checks passed
@rluisr rluisr deleted the fix/skip-unmatched-csv-files branch April 21, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant