[PR #711] [MERGED] validate api options fields from map #36174

Closed
opened 2026-04-22 20:52:59 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/711
Author: @BruceMacD
Created: 10/5/2023
Status: Merged
Merged: 10/12/2023
Merged by: @BruceMacD

Base: mainHead: brucemacd/validate-api-opts


📝 Commits (1)

  • 413a915 validate api options fields from map

📊 Changes

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

View changed files

📝 api/types.go (+9 -0)
📝 server/routes.go (+5 -1)

📄 Description

We use a map to set options from the API so that we can see which option fields were specified, otherwise we override default options with zero values. The issue here is that there was no validation that the input option fields were valid, so using an incorrect field by mistake did not return an error.

New response:

curl -X 'POST' -d '{"prompt":"hello", "model": "mistral", "options": {"seed": 1234, "temperature": 0, "test": 1234}}' 'http://127.0.0.1:11434/api/generate'
{"error":"invalid options: test"}

from #694


🔄 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/711 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 10/5/2023 **Status:** ✅ Merged **Merged:** 10/12/2023 **Merged by:** [@BruceMacD](https://github.com/BruceMacD) **Base:** `main` ← **Head:** `brucemacd/validate-api-opts` --- ### 📝 Commits (1) - [`413a915`](https://github.com/ollama/ollama/commit/413a9155e2c61f0ec04485a9eee455413a2ac015) validate api options fields from map ### 📊 Changes **2 files changed** (+14 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+9 -0) 📝 `server/routes.go` (+5 -1) </details> ### 📄 Description We use a map to set options from the API so that we can see which option fields were specified, otherwise we override default options with zero values. The issue here is that there was no validation that the input option fields were valid, so using an incorrect field by mistake did not return an error. New response: ``` curl -X 'POST' -d '{"prompt":"hello", "model": "mistral", "options": {"seed": 1234, "temperature": 0, "test": 1234}}' 'http://127.0.0.1:11434/api/generate' {"error":"invalid options: test"} ``` from #694 --- <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-22 20:52:59 -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#36174