[PR #14163] Fix missing error check in signinURL function #61242

Open
opened 2026-04-29 16:19:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14163
Author: @hobostay
Created: 2/9/2026
Status: 🔄 Open

Base: mainHead: fix/hostname-error-check


📝 Commits (1)

  • 14028f7 Fix missing error check in signinURL function

📊 Changes

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

View changed files

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

📄 Description

Summary

Fix a missing error check in the signinURL() function in server/routes.go.

Issue

The os.Hostname() call was ignoring its error return value:

h, _ := os.Hostname()

If hostname retrieval fails, an empty string would be used in the signin URL, which could lead to incorrect authentication URLs being generated.

Fix

Added proper error handling to return an error when hostname retrieval fails:

h, err := os.Hostname()
if err != nil {
    return "", fmt.Errorf("failed to get hostname: %w", err)
}

This ensures that:

  1. The caller is notified when hostname cannot be determined
  2. Malformed URLs are not generated silently
  3. Error handling is consistent with the rest of the function (which already returns errors for other failure cases)

Impact

  • Low risk: only affects error path when hostname retrieval fails
  • Improves robustness of authentication URL generation
  • Makes error handling explicit and consistent

Test plan

This is a defensive fix that adds error checking. The change only affects the error path when os.Hostname() fails (which is rare in practice). The normal flow remains unchanged.

🤖 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/14163 **Author:** [@hobostay](https://github.com/hobostay) **Created:** 2/9/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/hostname-error-check` --- ### 📝 Commits (1) - [`14028f7`](https://github.com/ollama/ollama/commit/14028f7796b597c82e2ad0c7851297765ad987d8) Fix missing error check in signinURL function ### 📊 Changes **1 file changed** (+4 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `server/routes.go` (+4 -1) </details> ### 📄 Description ## Summary Fix a missing error check in the `signinURL()` function in `server/routes.go`. ## Issue The `os.Hostname()` call was ignoring its error return value: ```go h, _ := os.Hostname() ``` If hostname retrieval fails, an empty string would be used in the signin URL, which could lead to incorrect authentication URLs being generated. ## Fix Added proper error handling to return an error when hostname retrieval fails: ```go h, err := os.Hostname() if err != nil { return "", fmt.Errorf("failed to get hostname: %w", err) } ``` This ensures that: 1. The caller is notified when hostname cannot be determined 2. Malformed URLs are not generated silently 3. Error handling is consistent with the rest of the function (which already returns errors for other failure cases) ## Impact - Low risk: only affects error path when hostname retrieval fails - Improves robustness of authentication URL generation - Makes error handling explicit and consistent ## Test plan This is a defensive fix that adds error checking. The change only affects the error path when `os.Hostname()` fails (which is rare in practice). The normal flow remains unchanged. 🤖 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-29 16:19:22 -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#61242