RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix NameError in audio chunker when file extension is missing or unsupported (#19007)
blueeeeblued032a3a98582
diff --git a/rag/app/audio.py b/rag/app/audio.pyindex 392b70ee99..1081093ebb 100644--- a/rag/app/audio.py+++ b/rag/app/audio.py@@ -30,6 +30,7 @@ def chunk(filename, binary, tenant_id, lang, callback=None, **kwargs):# is it Englishis_english = lang.lower() == "english" # is_english(sections)+ tmp_path = ""try:_, ext = os.path.splitext(filename)if not ext:@@ -38,7 +39,6 @@ def chunk(filename, binary, tenant_id, lang, callback=None, **kwargs):if ext not in [".da", ".wave", ".wav", ".mp3", ".aac", ".flac", ".ogg", ".aiff", ".au", ".midi", ".wma", ".realaudio", ".vqf", ".oggvorbis", ".ape"]:raise RuntimeError(f"Extension {ext} is not supported yet.")- tmp_path = ""with tempfile.NamedTemporaryFile(suffix=ext, delete=False) as tmpf:tmpf.write(binary)tmpf.flush()diff --git a/test/unit_test/rag/app/test_audio_invalid_extension.py b/test/unit_test/rag/app/test_audio_invalid_extension.pynew file mode 100644index 0000000000..24df0c18d7--- /dev/null+++ b/test/unit_test/rag/app/test_audio_invalid_extension.py@@ -0,0 +1,50 @@+#+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+#++from __future__ import annotations++import pytest++from rag.app import audio+++def test_missing_extension_reports_error():+ """A file without an extension is reported via the failure callback."""+ messages: list[tuple] = []++ def callback(prog=None, msg=""):+ messages.append((prog, msg))++ res = audio.chunk("no_extension_file", b"data", tenant_id="t", lang="english", callback=callback)++ assert res == []+ assert messages and messages[-1][0] == -1+ assert "No extension detected" in messages[-1][1]+++def test_unsupported_extension_reports_error():+ messages: list[tuple] = []++ def callback(prog=None, msg=""):+ messages.append((prog, msg))++ res = audio.chunk("song.xyz", b"data", tenant_id="t", lang="english", callback=callback)++ assert res == []+ assert messages and messages[-1][0] == -1+ assert "not supported yet" in messages[-1][1]