[PR #14975] [CLOSED] fix: use fallback hostname when os.Hostname() fails #46196

Closed
opened 2026-04-25 01:42:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14975
Author: @JasonOA888
Created: 3/20/2026
Status: Closed

Base: mainHead: fix/serve-bind-address-error-message-14963


📝 Commits (1)

  • b5d315a fix: use fallback hostname when os.Hostname() fails

📊 Changes

1 file changed (+4 additions, -1 deletions)

View changed files

📝 server/routes.go (+4 -1)

📄 Description

Summary

Fixes #14956

The signinURL() function in server/routes.go was silently ignoring errors from os.Hostname(), which could result in an empty name parameter in the sign-in URL.

Changes

  • Capture the error from os.Hostname()
  • Use "unknown" as a fallback when hostname cannot be determined
  • This ensures the sign-in URL always has a valid name parameter

Before

h, _ := os.Hostname()
return fmt.Sprintf(signinURLStr, url.PathEscape(h), encKey), nil
// h could be empty string if os.Hostname() fails

After

h, err := os.Hostname()
if err != nil {
    h = "unknown"
}
return fmt.Sprintf(signinURLStr, url.PathEscape(h), encKey), nil
// h is always a valid string

🔄 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/14975 **Author:** [@JasonOA888](https://github.com/JasonOA888) **Created:** 3/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/serve-bind-address-error-message-14963` --- ### 📝 Commits (1) - [`b5d315a`](https://github.com/ollama/ollama/commit/b5d315adf169bd50795eb00156d03f3e7004d221) fix: use fallback hostname when os.Hostname() fails ### 📊 Changes **1 file changed** (+4 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `server/routes.go` (+4 -1) </details> ### 📄 Description ## Summary Fixes #14956 The `signinURL()` function in `server/routes.go` was silently ignoring errors from `os.Hostname()`, which could result in an empty `name` parameter in the sign-in URL. ## Changes - Capture the error from `os.Hostname()` - Use `"unknown"` as a fallback when hostname cannot be determined - This ensures the sign-in URL always has a valid name parameter ## Before ```go h, _ := os.Hostname() return fmt.Sprintf(signinURLStr, url.PathEscape(h), encKey), nil // h could be empty string if os.Hostname() fails ``` ## After ```go h, err := os.Hostname() if err != nil { h = "unknown" } return fmt.Sprintf(signinURLStr, url.PathEscape(h), encKey), nil // h is always a valid string ``` --- <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-25 01:42:48 -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#46196