[PR #14563] envconfig: fall back to default on invalid bool env values #19994

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

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14563
Author: @umut-polat
Created: 3/2/2026
Status: 🔄 Open

Base: mainHead: fix/bool-with-default-fallback


📝 Commits (1)

  • 8e15620 envconfig: fall back to default on invalid bool env values

📊 Changes

2 files changed (+42 additions, -4 deletions)

View changed files

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

📄 Description

BoolWithDefault returned true when strconv.ParseBool failed instead of returning the provided default value. This caused boolean flags to be silently enabled when a user set an env var to a common but invalid string like "yes", "on", or "enabled".

The fix changes the error fallback from return true to return defaultValue.

Fixes #14389


🔄 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/14563 **Author:** [@umut-polat](https://github.com/umut-polat) **Created:** 3/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/bool-with-default-fallback` --- ### 📝 Commits (1) - [`8e15620`](https://github.com/ollama/ollama/commit/8e156202b02f1a53fc596ba50577d365ba2254bb) envconfig: fall back to default on invalid bool env values ### 📊 Changes **2 files changed** (+42 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `envconfig/config.go` (+1 -1) 📝 `envconfig/config_test.go` (+41 -3) </details> ### 📄 Description BoolWithDefault returned true when strconv.ParseBool failed instead of returning the provided default value. This caused boolean flags to be silently enabled when a user set an env var to a common but invalid string like "yes", "on", or "enabled". The fix changes the error fallback from `return true` to `return defaultValue`. Fixes #14389 --- <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:22: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#19994