Skip to content

Skip unsupported file types during source crawl - #303

Open
PuneetPunamiya wants to merge 1 commit into
redhat-data-and-ai:mainfrom
PuneetPunamiya:skip-unsupported-file-types
Open

Skip unsupported file types during source crawl#303
PuneetPunamiya wants to merge 1 commit into
redhat-data-and-ai:mainfrom
PuneetPunamiya:skip-unsupported-file-types

Conversation

@PuneetPunamiya

@PuneetPunamiya PuneetPunamiya commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
  • Only sync Docling-compatible document extensions from S3/GDrive and surface skipped files in the SourceCrawler Ready status message

Summary

  • Source crawler only downloads/stores supported document extensions (aligned with Docling from_formats, excluding image)
  • Unsupported files are skipped (not ingested) and listed in the SourceCrawler Ready condition message
  • Ready stays True when skips occur; real store/API failures still fail reconcile

Supported file types

  • .pdf
  • .md / .markdown
  • .docx
  • .pptx
  • .html / .htm
  • .csv
  • .xlsx
  • .adoc / .asciidoc

Not supported yet (skipped)

  • Images (.png, .jpg, .jpeg, .gif, .bmp, .tif, .tiff, .webp) — Docling image format intentionally excluded for now
  • .txt
  • .doc (legacy Word)
  • .ppt / .xls (legacy Office)
  • .odt / .ods / .odp
  • .rtf
  • .zip and other archives
  • Any other extension not in the supported list above

Example status

status:
  conditions:
    - type: SourceCrawlerReady
      status: "True"
      reason: SuccessfullyReconciled
      message: >-
        successfully reconciled source crawler: my-pipeline-crawl;
        skipped 2 unsupported file(s): documents/photo.png, documents/notes.txt

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * S3 and Google Drive syncs now skip unsupported file types and report which files were skipped.
  * Reconciliation messages include a capped list of skipped files and the number of additional files.
  * Supported document formats are recognized consistently, regardless of file-extension capitalization.

* **Bug Fixes**
  * Unsupported files are filtered before storage or download, improving synchronization reliability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Only sync Docling-compatible document extensions from S3/GDrive and
surface skipped files in the SourceCrawler Ready status message.
@PuneetPunamiya
PuneetPunamiya force-pushed the skip-unsupported-file-types branch from 158b794 to 5c95467 Compare July 31, 2026 07:27
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Enterprise

Run ID: 192a1457-8d8f-4f2e-8b13-e4800544675e

📥 Commits

Reviewing files that changed from the base of the PR and between 7abca92 and 5c95467.

📒 Files selected for processing (3)
  • internal/controller/sourcecrawler_controller.go
  • pkg/unstructured/file_types.go
  • pkg/unstructured/source.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/unstructured/source.go
  • internal/controller/sourcecrawler_controller.go

📝 Walkthrough

Walkthrough

The change defines supported document extensions, filters unsupported files during S3 and Google Drive synchronization, records skipped files, and includes capped skipped-file details in successful reconciliation messages.

Changes

Unsupported File Handling

Layer / File(s) Summary
Supported file type contract
pkg/unstructured/file_types.go
Defines supported document extensions. Adds case-insensitive file-type checks and normalized extension extraction.
Source synchronization filtering
pkg/unstructured/source.go
S3 and Google Drive sources reset and populate SkippedUnsupported. Unsupported files are excluded from storage and download scheduling.
Skipped-file reconciliation reporting
internal/controller/sourcecrawler_controller.go
Successful status messages report skipped-file counts and names. Displayed names are limited to ten, with an additional-count suffix when needed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: skipping unsupported file types during source crawling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
pkg/unstructured/file_types.go (1)

26-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider making the extension set immutable to callers.

SupportedFileExtensions is an exported map[string]bool. Any package that imports unstructured can add or remove entries at runtime, for example unstructured.SupportedFileExtensions[".txt"] = true. This would change filtering behavior for all S3BucketSource and GDriveSource instances without going through IsSupportedFileType.

Unexport the map and keep only IsSupportedFileType and FileExtension as the public surface, or expose a copy through an accessor function.

♻️ Proposed fix
-// SupportedFileExtensions mirrors Docling defaultFromFormats, excluding image.
-// Supported: docx, pptx, html, pdf, asciidoc, md, csv, xlsx.
-var SupportedFileExtensions = map[string]bool{
+// supportedFileExtensions mirrors Docling defaultFromFormats, excluding image.
+// Supported: docx, pptx, html, pdf, asciidoc, md, csv, xlsx.
+var supportedFileExtensions = map[string]bool{
 	".docx":     true,
 	".pptx":     true,
 	".html":     true,
 	".htm":      true,
 	".pdf":      true,
 	".adoc":     true,
 	".asciidoc": true,
 	".md":       true,
 	".markdown": true,
 	".csv":      true,
 	".xlsx":     true,
 }

 func IsSupportedFileType(fileName string) bool {
-	return SupportedFileExtensions[strings.ToLower(path.Ext(fileName))]
+	return supportedFileExtensions[strings.ToLower(path.Ext(fileName))]
+}
+
+// IsSupportedExtension checks a pre-computed, normalized extension (e.g. an
+// extension overridden for Google-native document conversion).
+func IsSupportedExtension(ext string) bool {
+	return supportedFileExtensions[strings.ToLower(ext)]
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/unstructured/file_types.go` around lines 26 - 38, Make the supported
extension collection private instead of exposing the mutable
SupportedFileExtensions map. Update IsSupportedFileType and FileExtension to use
the private collection, preserving their existing public behavior; if callers
require access, provide a copy-returning accessor rather than the underlying
map.
internal/controller/sourcecrawler_controller.go (1)

315-324: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider moving skipped-file reporting onto the DataSource interface.

skippedUnsupportedFromSource type-switches on *unstructured.S3BucketSource and *unstructured.GDriveSource. This works today because Reconcile only constructs these two types. If a future DataSource implementation is added and this switch is not updated, its skipped files silently disappear from the status message with no compile-time warning.

Add a method to the DataSource interface in pkg/unstructured/source.go instead, so every implementation must supply its own skipped-file list.

♻️ Proposed fix
 type DataSource interface {
 	// SyncFilesToFilestore will store all files from the source to the filestore and return the list of file paths
 	SyncFilesToFilestore(ctx context.Context, fs *filestore.FileStore) ([]RawFileMetadata, error)
+	// SkippedUnsupportedFiles returns file paths skipped during the last sync
+	// due to an unsupported extension.
+	SkippedUnsupportedFiles() []string
 }
-func skippedUnsupportedFromSource(source unstructured.DataSource) []string {
-	switch s := source.(type) {
-	case *unstructured.S3BucketSource:
-		return s.SkippedUnsupported
-	case *unstructured.GDriveSource:
-		return s.SkippedUnsupported
-	default:
-		return nil
-	}
-}
+func skippedUnsupportedFromSource(source unstructured.DataSource) []string {
+	return source.SkippedUnsupportedFiles()
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/controller/sourcecrawler_controller.go` around lines 315 - 324, Move
skipped-file reporting into the DataSource interface by adding a method that
returns the source’s skipped unsupported files, and implement it for
S3BucketSource and GDriveSource. Update skippedUnsupportedFromSource to call
that interface method directly and remove its concrete-type switch, ensuring
future DataSource implementations must provide the behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/controller/sourcecrawler_controller.go`:
- Around line 315-324: Move skipped-file reporting into the DataSource interface
by adding a method that returns the source’s skipped unsupported files, and
implement it for S3BucketSource and GDriveSource. Update
skippedUnsupportedFromSource to call that interface method directly and remove
its concrete-type switch, ensuring future DataSource implementations must
provide the behavior.

In `@pkg/unstructured/file_types.go`:
- Around line 26-38: Make the supported extension collection private instead of
exposing the mutable SupportedFileExtensions map. Update IsSupportedFileType and
FileExtension to use the private collection, preserving their existing public
behavior; if callers require access, provide a copy-returning accessor rather
than the underlying map.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Enterprise

Run ID: cbf8ee34-b863-44a0-b8a5-15ccce6fe5e8

📥 Commits

Reviewing files that changed from the base of the PR and between 7abca92 and 5c95467.

📒 Files selected for processing (3)
  • internal/controller/sourcecrawler_controller.go
  • pkg/unstructured/file_types.go
  • pkg/unstructured/source.go

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