[GH-ISSUE #14250] Panic in list command when model digest is shorter than 12 characters #55790

Open
opened 2026-04-29 09:44:24 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @BurakBebek1 on GitHub (Feb 14, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/14250

What is the issue?

Description

A runtime panic occurs when running ./ollama list if a model has a digest (ID) shorter than 12 characters. This happens because the code unconditionally attempts to slice the digest string using [:12] without checking its actual length.

Steps to Reproduce

Introduce a model with a short digest (e.g., via a malformed manifest or manual code injection).

Run ./ollama list.

The application crashes with: panic: runtime error: slice bounds out of range [:12].

Observed Behavior

The program terminates abruptly:

panic: runtime error: slice bounds out of range [:12] with length 3
goroutine 1 [running]:
github.com/ollama/ollama/cmd.ListHandler(...)
/home/turko/ollama/cmd/cmd.go:835

Expected Behavior

The command should list the models safely, showing the full digest if it's short, or a placeholder if it's empty, without crashing the CLI.

Proposed Fix

Implement a bounds check before slicing the digest string in cmd/cmd.go:

displayID := m.Digest
if len(displayID) > 12 {
displayID = displayID[:12]
}

Relevant log output


OS

WSL2

GPU

Nvidia

CPU

Intel

Ollama version

0.0.0 (locally built from source)

Originally created by @BurakBebek1 on GitHub (Feb 14, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/14250 ### What is the issue? ### Description A runtime panic occurs when running ./ollama list if a model has a digest (ID) shorter than 12 characters. This happens because the code unconditionally attempts to slice the digest string using [:12] without checking its actual length. --- ### Steps to Reproduce Introduce a model with a short digest (e.g., via a malformed manifest or manual code injection). Run ./ollama list. The application crashes with: panic: runtime error: slice bounds out of range [:12]. --- ### Observed Behavior The program terminates abruptly: panic: runtime error: slice bounds out of range [:12] with length 3 goroutine 1 [running]: github.com/ollama/ollama/cmd.ListHandler(...) /home/turko/ollama/cmd/cmd.go:835 ### Expected Behavior The command should list the models safely, showing the full digest if it's short, or a placeholder if it's empty, without crashing the CLI. --- ### Proposed Fix Implement a bounds check before slicing the digest string in cmd/cmd.go: displayID := m.Digest if len(displayID) > 12 { displayID = displayID[:12] } ### Relevant log output ```shell ``` ### OS WSL2 ### GPU Nvidia ### CPU Intel ### Ollama version 0.0.0 (locally built from source)
GiteaMirror added the bug label 2026-04-29 09:44:24 -05:00
Author
Owner

@driftttttt commented on GitHub (Feb 14, 2026):

checked the source, it indeed panics at line 835 in cmd/cmd.go. bounds check is missing there. simple if len > 12 should fix it.

<!-- gh-comment-id:3902741216 --> @driftttttt commented on GitHub (Feb 14, 2026): checked the source, it indeed panics at line 835 in cmd/cmd.go. bounds check is missing there. simple if len > 12 should fix it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#55790