JanDeDobbeleer/oh-my-posh · error

missing Brewfather api key (api_key)

Error message

missing Brewfather api key (api_key)

What it means

The Brewfather segment requires a Brewfather API key to authenticate against api.brewfather.app. Before making any HTTP request, getResult() resolves the `api_key` template option; if the resolved value is an empty string it returns this error. It is a configuration error, not a network failure.

Source

Thrown at src/segments/brewfather.go:197

		return bf.options.String(BFConditioningStatusIcon, "\uE372")
	case BFStatusCompleted:
		return bf.options.String(BFCompletedStatusIcon, "\uF7A5")
	case BFStatusArchived:
		return bf.options.String(BFArchivedStatusIcon, "\uF187")
	default:
		return ""
	}
}

func (bf *Brewfather) getResult() (*Batch, error) {
	userID := bf.options.Template(BFUserID, "", bf)
	if userID == "" {
		return nil, errors.New("missing Brewfather user id (user_id)")
	}

	apiKey := bf.options.Template(APIKey, "", bf)
	if apiKey == "" {
		return nil, errors.New("missing Brewfather api key (api_key)")
	}

	batchID := bf.options.Template(BFBatchID, "", bf)
	if batchID == "" {
		return nil, errors.New("missing Brewfather batch id (batch_id)")
	}

	authString := fmt.Sprintf("%s:%s", userID, apiKey)
	authStringb64 := base64.StdEncoding.EncodeToString([]byte(authString))
	authHeader := fmt.Sprintf("Basic %s", authStringb64)
	batchURL := fmt.Sprintf("https://api.brewfather.app/v1/batches/%s", batchID)
	batchReadingsURL := fmt.Sprintf("https://api.brewfather.app/v1/batches/%s/readings", batchID)

	httpTimeout := bf.options.Int(options.HTTPTimeout, options.DefaultHTTPTimeout)

	// batch
	addAuthHeader := func(request *http.Request) {
		request.Header.Add("authorization", authHeader)

View on GitHub (pinned to 0976794618)

Solutions

  1. Add `api_key` to the brewfather segment block in your theme config with your Brewfather API key (from Brewfather > Settings > API).
  2. If api_key is a template expression, verify the referenced env var/property is set in the shell where the prompt renders.
  3. Temporarily disable the segment if you don't intend to use Brewfather.

Example fix

// before
{"type": "brewfather", "user_id": "abc"}
// after
{"type": "brewfather", "user_id": "abc", "api_key": "your-brewfather-api-key"}
Defensive patterns

Strategy: validation

Validate before calling

// theme config check before enabling the segment
if segment.ApiKey == "" { /* remove segment or set api_key */ }

Prevention

When it happens

Trigger: The brewfather segment is enabled but the `api_key` option (or the template that resolves it) is missing, empty, or evaluates to empty at render time.

Common situations: User added the segment to their theme but forgot to add `api_key`; the key was stored in an env var or template expression that resolves to empty in this shell; key was deleted during theme refactoring.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/4c5b37716639cff6. Report an issue: GitHub.