[PR #14453] fix: prevent panic when model digest is shorter than 12 characters #19949

Open
opened 2026-04-16 07:21:39 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14453
Author: @Anandesh-Sharma
Created: 2/26/2026
Status: 🔄 Open

Base: mainHead: fix-short-digest-panic


📝 Commits (1)

  • ff49009 fix: prevent panic when model digest is shorter than 12 characters

📊 Changes

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

View changed files

📝 cmd/cmd.go (+10 -2)

📄 Description

Summary

  • Add bounds check before slicing model digest strings in ListHandler and ListRunningHandler
  • If digest is shorter than 12 characters, display the full digest instead of panicking

Details

The ollama list and ollama ps commands unconditionally slice m.Digest[:12] to display a truncated model ID. If a model has a digest shorter than 12 characters (e.g., from a malformed manifest), this causes a runtime panic:

panic: runtime error: slice bounds out of range [:12] with length 3

This fix adds a simple length check at both call sites in cmd/cmd.go.

Test plan

  • Verified the fix handles short digests by showing full digest
  • Normal digests (>12 chars) continue to be truncated as before

Fixes #14250

🤖 Generated with Claude Code


🔄 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/14453 **Author:** [@Anandesh-Sharma](https://github.com/Anandesh-Sharma) **Created:** 2/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-short-digest-panic` --- ### 📝 Commits (1) - [`ff49009`](https://github.com/ollama/ollama/commit/ff49009022064fc901db74842cab2a03492299d5) fix: prevent panic when model digest is shorter than 12 characters ### 📊 Changes **1 file changed** (+10 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+10 -2) </details> ### 📄 Description ## Summary - Add bounds check before slicing model digest strings in `ListHandler` and `ListRunningHandler` - If digest is shorter than 12 characters, display the full digest instead of panicking ## Details The `ollama list` and `ollama ps` commands unconditionally slice `m.Digest[:12]` to display a truncated model ID. If a model has a digest shorter than 12 characters (e.g., from a malformed manifest), this causes a runtime panic: ``` panic: runtime error: slice bounds out of range [:12] with length 3 ``` This fix adds a simple length check at both call sites in `cmd/cmd.go`. ## Test plan - [x] Verified the fix handles short digests by showing full digest - [x] Normal digests (>12 chars) continue to be truncated as before Fixes #14250 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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-16 07:21:39 -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#19949