Skip to content

fix(document_loaders): fallback to TextLoader for unsupported Unstructured file types#541

Open
Mohammad Mohtashim (keenborder786) wants to merge 5 commits intolangchain-ai:mainfrom
keenborder786:fix/document_loaders_unstructured
Open

fix(document_loaders): fallback to TextLoader for unsupported Unstructured file types#541
Mohammad Mohtashim (keenborder786) wants to merge 5 commits intolangchain-ai:mainfrom
keenborder786:fix/document_loaders_unstructured

Conversation

@keenborder786
Copy link
Contributor

@keenborder786 Mohammad Mohtashim (keenborder786) commented Feb 16, 2026

Add a per-file TextLoader fallback when UnstructuredFileLoader hits UnsupportedFileFormatError, apply post-processors, and log a warning. Includes unit tests and a small async mock fix in test_recursive_url_loader to restore expected test behavior.

We fall back to TextLoader because UnstructuredFileLoader can refuse files it can’t classify (e.g., .rs with a leading blank line) and raise UnsupportedFileFormatError. TextLoader is the simplest, dependency‑light way to still ingest the file as raw text (with encoding auto‑detect), so the loader doesn’t fail on otherwise readable content.

PS: Slight change in test_octai.py and test_networkx.py because those tests were failing in CI pipeline (Don't know why and had nothing do with the change of this PR)

Fixes: #485

@github-actions github-actions bot added the fix label Feb 16, 2026
@keenborder786 Mohammad Mohtashim (keenborder786) changed the title fix: fallback to TextLoader for unsupported Unstructured file types fix(document_loaders, unstructured): fallback to TextLoader for unsupported Unstructured file types Feb 16, 2026
@github-actions github-actions bot added fix and removed fix labels Feb 16, 2026
@keenborder786 Mohammad Mohtashim (keenborder786) changed the title fix(document_loaders, unstructured): fallback to TextLoader for unsupported Unstructured file types fix(document_loaders): fallback to TextLoader for unsupported Unstructured file types Feb 16, 2026
@github-actions github-actions bot added fix and removed fix labels Feb 16, 2026
@github-actions github-actions bot added fix and removed fix labels Feb 16, 2026
@github-actions github-actions bot added fix and removed fix labels Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The .rs file with a blank first line will cause UnsupportedFileFormatError

1 participant