JanDeDobbeleer/oh-my-posh · error

missing Brewfather batch id (batch_id)

Error message

missing Brewfather batch id (batch_id)

What it means

The Brewfather segment fetches a specific batch by ID from the Brewfather API. After validating user_id and api_key, getResult() resolves the `batch_id` option; if empty it returns this error instead of calling the API. It is purely a configuration error.

Source

Thrown at src/segments/brewfather.go:202

	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)
	}

	body, err := bf.env.HTTPRequest(batchURL, nil, httpTimeout, addAuthHeader)
	if err != nil {
		return nil, err

View on GitHub (pinned to 0976794618)

Solutions

  1. Add `batch_id` to the brewfather segment block with the ID of the batch to display (visible in the Brewfather batch URL).
  2. If batch_id is a template expression, confirm the referenced value resolves non-empty in your shell.
  3. Disable the segment if no batch should be tracked.

Example fix

// before
{"type": "brewfather", "user_id": "abc", "api_key": "key"}
// after
{"type": "brewfather", "user_id": "abc", "api_key": "key", "batch_id": "AbCdEf123"}
Defensive patterns

Strategy: validation

Validate before calling

if segment.BatchId == "" { /* set batch_id from the Brewfather batch URL */ }

Prevention

When it happens

Trigger: The brewfather segment is enabled with user_id and api_key set, but the `batch_id` option is missing or its template resolves to an empty string.

Common situations: User set up credentials but forgot the batch ID; the batch was archived/deleted and the ID removed from config; template referencing a property that no longer exists.

Related errors


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