This is an automated email from the ASF dual-hosted git repository.
guan404ming pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new d6246920c30 Fix DocumentLoaderOperator ignoring unknown parser on byte
input (#70071)
d6246920c30 is described below
commit d6246920c30520e0d78319a4f74a76f35058ee93
Author: Guan-Ming Chiu <[email protected]>
AuthorDate: Sun Jul 19 11:56:31 2026 +0800
Fix DocumentLoaderOperator ignoring unknown parser on byte input (#70071)
* Fix DocumentLoaderOperator ignoring unknown parser on byte input
* Validate explicit parser in _resolve_backend
---
.../ai/src/airflow/providers/common/ai/operators/document_loader.py | 2 ++
.../common/ai/tests/unit/common/ai/operators/test_document_loader.py | 5 +++++
2 files changed, 7 insertions(+)
diff --git
a/providers/common/ai/src/airflow/providers/common/ai/operators/document_loader.py
b/providers/common/ai/src/airflow/providers/common/ai/operators/document_loader.py
index 7f563d0aa4a..b452cab72ed 100644
---
a/providers/common/ai/src/airflow/providers/common/ai/operators/document_loader.py
+++
b/providers/common/ai/src/airflow/providers/common/ai/operators/document_loader.py
@@ -289,6 +289,8 @@ class DocumentLoaderOperator(BaseOperator):
def _resolve_backend(self, ext: str) -> str:
if self.parser != "auto":
+ if self.parser not in set(self.EXTENSION_BACKEND_MAP.values()):
+ raise ValueError(f"No parser found for backend
'{self.parser}'.")
return self.parser
ext = ext.lower()
diff --git
a/providers/common/ai/tests/unit/common/ai/operators/test_document_loader.py
b/providers/common/ai/tests/unit/common/ai/operators/test_document_loader.py
index bb9db83347c..6681c0f463d 100644
--- a/providers/common/ai/tests/unit/common/ai/operators/test_document_loader.py
+++ b/providers/common/ai/tests/unit/common/ai/operators/test_document_loader.py
@@ -410,6 +410,11 @@ class TestFileDiscovery:
with pytest.raises(ValueError, match="No parser registered"):
op.execute(context=MagicMock())
+ def test_unknown_parser_on_source_bytes_raises(self):
+ op = DocumentLoaderOperator(task_id="test", source_bytes=b"a,b\n1,2",
file_type=".csv", parser="cvs")
+ with pytest.raises(ValueError, match="No parser found"):
+ op.execute(context=MagicMock())
+
def test_nonexistent_glob_raises_file_not_found(self, tmp_path):
op = DocumentLoaderOperator(task_id="test", source_path=str(tmp_path /
"*.nope"))
with pytest.raises(FileNotFoundError, match="No files found"):