[PR #14398] envconfig: fix BoolWithDefault to return defaultValue on parse error #19927

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

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14398
Author: @sxu75374
Created: 2/24/2026
Status: 🔄 Open

Base: mainHead: fix/boolwithdefault-fallback


📝 Commits (1)

  • 879d5d7 envconfig: fix BoolWithDefault to return defaultValue on parse error

📊 Changes

2 files changed (+3 additions, -3 deletions)

View changed files

📝 envconfig/config.go (+1 -1)
📝 envconfig/config_test.go (+2 -2)

📄 Description

BoolWithDefault returned true for any value that strconv.ParseBool couldn't parse, ignoring the caller-supplied default. This meant Bool (which passes false as the default) would silently enable features when an env var contained a typo or unexpected string.

Now the function returns defaultValue on parse failure, so the fallback honours the caller's intent.


🔄 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/14398 **Author:** [@sxu75374](https://github.com/sxu75374) **Created:** 2/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/boolwithdefault-fallback` --- ### 📝 Commits (1) - [`879d5d7`](https://github.com/ollama/ollama/commit/879d5d77c6d1d6faa30e172c99e964a10f51e17c) envconfig: fix BoolWithDefault to return defaultValue on parse error ### 📊 Changes **2 files changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `envconfig/config.go` (+1 -1) 📝 `envconfig/config_test.go` (+2 -2) </details> ### 📄 Description `BoolWithDefault` returned `true` for any value that `strconv.ParseBool` couldn't parse, ignoring the caller-supplied default. This meant `Bool` (which passes `false` as the default) would silently enable features when an env var contained a typo or unexpected string. Now the function returns `defaultValue` on parse failure, so the fallback honours the caller's intent. --- <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:05 -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#19927