[PR #12176] [MERGED] parser: don't check the file type of safetensors to prevent false negatives. #39600

Closed
opened 2026-04-23 00:33:59 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/12176
Author: @rick-github
Created: 9/3/2025
Status: Merged
Merged: 9/5/2025
Merged by: @pdevine

Base: mainHead: safetensors


📝 Commits (2)

  • e90ac3e Don't check the file type of safetensor to prevent false negatives.
  • bde9ea6 comment

📊 Changes

1 file changed (+3 additions, -2 deletions)

View changed files

📝 parser/parser.go (+3 -2)

📄 Description

The server tries to verify that the safetensor files are application/octet-stream by using http.DetectContentType() to determine the type of the contents of the file. The safetensor format is pretty simple, with the first 8 bytes being the length of the following header. Unfortunately the length of the header in model-00001-of-00050.safetensors is 256 bytes, or 00 01 00 00 00 00 00 00, and this matches the pattern for font/ttf. So the server is skipping the safetensor files because at least one of them looks like a font file.

Modify the test to skip checking the filetype for safetensors; keep the glob matching and prefix loading to verify the files are readable.

Fixes: #11897


🔄 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/12176 **Author:** [@rick-github](https://github.com/rick-github) **Created:** 9/3/2025 **Status:** ✅ Merged **Merged:** 9/5/2025 **Merged by:** [@pdevine](https://github.com/pdevine) **Base:** `main` ← **Head:** `safetensors` --- ### 📝 Commits (2) - [`e90ac3e`](https://github.com/ollama/ollama/commit/e90ac3efb050c86da255e974c4fe3e464ed7befe) Don't check the file type of safetensor to prevent false negatives. - [`bde9ea6`](https://github.com/ollama/ollama/commit/bde9ea6659659e3f9c5a4eb3b73a72c1b94226fa) comment ### 📊 Changes **1 file changed** (+3 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `parser/parser.go` (+3 -2) </details> ### 📄 Description The server tries to verify that the safetensor files are `application/octet-stream` by using `http.DetectContentType()` to determine the type of the contents of the file. The safetensor [format](https://huggingface.co/docs/safetensors/en/index#format) is pretty simple, with the first 8 bytes being the length of the following header. Unfortunately the length of the header in model-00001-of-00050.safetensors is 256 bytes, or `00 01 00 00 00 00 00 00`, and this [matches](https://cs.opensource.google/go/go/+/refs/tags/go1.25.1:src/net/http/sniff.go;l=174) the [pattern](https://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern:~:text=Embedded%20OpenType%20signature.-,00%2001%2000%2000,-FF%20FF%20FF) for `font/ttf`. So the server is skipping the safetensor files because at least one of them looks like a font file. Modify the test to skip checking the filetype for safetensors; keep the glob matching and prefix loading to verify the files are readable. Fixes: #11897 --- <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-23 00:33: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#39600