[PR #14987] fix: use fallback hostname when os.Hostname() fails #20225

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

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14987
Author: @JasonOA888
Created: 3/21/2026
Status: 🔄 Open

Base: mainHead: fix/hostname-fallback-with-warning


📝 Commits (1)

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

📊 Changes

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

View changed files

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

📄 Description

Summary

Fixes #14956

Per @guicybercode feedback on #14975, this version adds a warning log when the fallback triggers.

Changes

  • Capture the error from os.Hostname()
  • Log a warning with slog.Warn() when hostname cannot be determined
  • Use "unknown" as fallback value
  • This allows operators to detect when os.Hostname() fails, which usually indicates a deeper system misconfiguration

Example Log Output

WARN os.Hostname() failed, using fallback error="gethostname: hostname too long"

🔄 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/14987 **Author:** [@JasonOA888](https://github.com/JasonOA888) **Created:** 3/21/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/hostname-fallback-with-warning` --- ### 📝 Commits (1) - [`4a07bb7`](https://github.com/ollama/ollama/commit/4a07bb785d9cba24b2eb27f594be49909012f2a7) fix: use fallback hostname when os.Hostname() fails ### 📊 Changes **1 file changed** (+5 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `server/routes.go` (+5 -1) </details> ### 📄 Description ## Summary Fixes #14956 Per @guicybercode feedback on #14975, this version adds a warning log when the fallback triggers. ## Changes - Capture the error from `os.Hostname()` - Log a warning with `slog.Warn()` when hostname cannot be determined - Use `"unknown"` as fallback value - This allows operators to detect when `os.Hostname()` fails, which usually indicates a deeper system misconfiguration ## Example Log Output ``` WARN os.Hostname() failed, using fallback error="gethostname: hostname too long" ``` --- <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:30:47 -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#20225