[PR #14813] envconfig: prevent panic when OLLAMA_ORIGINS have a tailing comma #25392

Open
opened 2026-04-19 18:11:31 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14813
Author: @qyl27
Created: 3/13/2026
Status: 🔄 Open

Base: mainHead: fix-empty-cors-origin-panic


📝 Commits (2)

  • 34e71ff envconfig: prevent panic when OLLAMA_ORIGINS have a tailing comma
  • 41a1b24 envconfig: test for ignoring empty string in origins

📊 Changes

2 files changed (+25 additions, -1 deletions)

View changed files

📝 envconfig/config.go (+3 -1)
📝 envconfig/config_test.go (+22 -0)

📄 Description

This PR is about robustness.

Currently, it will panic when OLLAMA_ORIGINS was set to http://example.com,. It has a comma tailing, and was split into ["http://example.com", ""], the empty string should be filtered, or we got panic: bad origin: origins must contain '*' or include http://,https://,chrome-extension://,safari-extension://,moz-extension://,ms-browser-extension://.

With this PR, we can use set OLLAMA_ORIGINS="http://example.com,$OLLAMA_ORIGINS" to append a CORS origin.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14813 **Author:** [@qyl27](https://github.com/qyl27) **Created:** 3/13/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-empty-cors-origin-panic` --- ### 📝 Commits (2) - [`34e71ff`](https://github.com/ollama/ollama/commit/34e71fff3aa292064d592528795a072cd2b49627) envconfig: prevent panic when `OLLAMA_ORIGINS` have a tailing comma - [`41a1b24`](https://github.com/ollama/ollama/commit/41a1b2443d15ba24bc10c5641d2e5be9c490af67) envconfig: test for ignoring empty string in origins ### 📊 Changes **2 files changed** (+25 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `envconfig/config.go` (+3 -1) 📝 `envconfig/config_test.go` (+22 -0) </details> ### 📄 Description This PR is about robustness. Currently, it will panic when `OLLAMA_ORIGINS` was set to `http://example.com,`. It has a comma tailing, and was split into `["http://example.com", ""]`, the empty string should be filtered, or we got `panic: bad origin: origins must contain '*' or include http://,https://,chrome-extension://,safari-extension://,moz-extension://,ms-browser-extension://`. With this PR, we can use `set OLLAMA_ORIGINS="http://example.com,$OLLAMA_ORIGINS"` to append a CORS origin. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 18:11:31 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#25392