Skip to content

Commit 2c35bdb

Browse files
alvinttanggambletanclaude
authored
fix: replace bare string raises with proper exception types (open-webui#22446)
`raise "string"` in Python raises TypeError instead of the intended error, making error messages confusing and debugging difficult. Co-authored-by: gambletan <ethanchang32@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent abe865f commit 2c35bdb

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

backend/open_webui/retrieval/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ def generate_openai_batch_embeddings(
590590
if "data" in data:
591591
return [elem["embedding"] for elem in data["data"]]
592592
else:
593-
raise "Something went wrong :/"
593+
raise ValueError("Unexpected OpenAI embeddings response: missing 'data' key")
594594
except Exception as e:
595595
log.exception(f"Error generating openai batch embeddings: {e}")
596596
return None
@@ -767,7 +767,7 @@ def generate_ollama_batch_embeddings(
767767
if "embeddings" in data:
768768
return data["embeddings"]
769769
else:
770-
raise "Something went wrong :/"
770+
raise ValueError("Unexpected Ollama embeddings response: missing 'embeddings' key")
771771
except Exception as e:
772772
log.exception(f"Error generating ollama batch embeddings: {e}")
773773
return None

backend/open_webui/routers/ollama.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ async def download_file_stream(
17471747

17481748
yield f"data: {json.dumps(res)}\n\n"
17491749
else:
1750-
raise "Ollama: Could not create blob, Please try again."
1750+
raise RuntimeError("Ollama: Could not create blob, Please try again.")
17511751

17521752

17531753
# url = "https://huggingface.co/TheBloke/stablelm-zephyr-3b-GGUF/resolve/main/stablelm-zephyr-3b.Q2_K.gguf"

0 commit comments

Comments
 (0)