we-promise/sure · error · Family::AutoCategorizer::Error

No LLM provider for auto-categorization

Error message

No LLM provider for auto-categorization

What it means

Family::AutoCategorizer#auto_categorize raises immediately when llm_provider is nil. llm_provider resolves through Provider::Registry.preferred_llm_provider (app/models/provider/registry.rb:26), which honors Setting.llm_provider ordering and returns nil only when NEITHER the OpenAI nor the Anthropic provider has credentials configured on the install.

Solutions

  1. Configure credentials for OpenAI or Anthropic (the registry reads them from ENV) and restart the app
  2. Set Setting.llm_provider to the credentialed provider to control the fallback order
  3. Guard callers: skip or schedule later unless Provider::Registry.preferred_llm_provider is present, and surface a 'configure an LLM provider' hint instead of an exception

Example fix

// before
Family::AutoCategorizer.new(family, transaction_ids: ids).auto_categorize

// after
if Provider::Registry.preferred_llm_provider
  Family::AutoCategorizer.new(family, transaction_ids: ids).auto_categorize
else
  Rails.logger.info('Auto-categorization skipped: no LLM provider configured')
end
Defensive patterns

Strategy: validation

Validate before calling

Provider::Registry.preferred_llm_provider.present? # false => auto_categorize will raise immediately

Try / catch

rescue Family::AutoCategorizer::Error => e; if e.message == 'No LLM provider for auto-categorization', surface a setup prompt instead of retrying (retry cannot fix missing credentials)

Prevention

When it happens

Trigger: Invoking auto_categorize on an install where no LLM provider credentials are set: preferred_llm_provider tries openai then anthropic (or the reverse when Setting.llm_provider == 'anthropic'), gets nil from both, and returns nil, so the guard fires.

Common situations: Self-hosted installs missing the OpenAI/Anthropic ENV credentials; staging with providers disabled; running auto-categorization jobs before provider setup completed after an upgrade that introduced the registry.

Related errors


AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21). Data as JSON: /api/errors/470f52a5fdf44914. Report an issue: GitHub.

Appendix: source

Thrown at app/models/family/auto_categorizer.rb:10

class Family::AutoCategorizer
  Error = Class.new(StandardError)

  def initialize(family, transaction_ids: [])
    @family = family
    @transaction_ids = transaction_ids
  end

  def auto_categorize
    raise Error, "No LLM provider for auto-categorization" unless llm_provider

    if scope.none?
      Rails.logger.info("No transactions to auto-categorize for family #{family.id}")
      return 0
    else
      Rails.logger.info("Auto-categorizing #{scope.count} transactions for family #{family.id}")
    end

    categories_input = user_categories_input

    if categories_input.empty?
      Rails.logger.error("Cannot auto-categorize transactions for family #{family.id}: no categories available")
      return 0
    end

    result = llm_provider.auto_categorize(
      transactions: transactions_input,
      user_categories: categories_input,

View on GitHub (pinned to e69894adb9)