{"record":{"id":"470f52a5fdf44914","repo":"we-promise/sure","slug":"no-llm-provider-for-auto-categorization","errorCode":null,"errorMessage":"No LLM provider for auto-categorization","messagePattern":"No LLM provider for auto-categorization","errorType":"exception","errorClass":"Family::AutoCategorizer::Error","httpStatus":null,"severity":"error","filePath":"app/models/family/auto_categorizer.rb","lineNumber":10,"sourceCode":"class Family::AutoCategorizer\n  Error = Class.new(StandardError)\n\n  def initialize(family, transaction_ids: [])\n    @family = family\n    @transaction_ids = transaction_ids\n  end\n\n  def auto_categorize\n    raise Error, \"No LLM provider for auto-categorization\" unless llm_provider\n\n    if scope.none?\n      Rails.logger.info(\"No transactions to auto-categorize for family #{family.id}\")\n      return 0\n    else\n      Rails.logger.info(\"Auto-categorizing #{scope.count} transactions for family #{family.id}\")\n    end\n\n    categories_input = user_categories_input\n\n    if categories_input.empty?\n      Rails.logger.error(\"Cannot auto-categorize transactions for family #{family.id}: no categories available\")\n      return 0\n    end\n\n    result = llm_provider.auto_categorize(\n      transactions: transactions_input,\n      user_categories: categories_input,","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/family/auto_categorizer.rb#L1-L28","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Configure credentials for OpenAI or Anthropic (the registry reads them from ENV) and restart the app","Set Setting.llm_provider to the credentialed provider to control the fallback order","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"],"exampleFix":"// before\nFamily::AutoCategorizer.new(family, transaction_ids: ids).auto_categorize\n\n// after\nif Provider::Registry.preferred_llm_provider\n  Family::AutoCategorizer.new(family, transaction_ids: ids).auto_categorize\nelse\n  Rails.logger.info('Auto-categorization skipped: no LLM provider configured')\nend","handlingStrategy":"validation","validationCode":"Provider::Registry.preferred_llm_provider.present? # false => auto_categorize will raise immediately","typeGuard":null,"tryCatchPattern":"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)","preventionTips":["Set credentials for OpenAI or Anthropic before enabling auto-categorization features","Guard job scheduling on Provider::Registry.preferred_llm_provider","Distinguish the 'no provider' error (configuration, do not retry) from provider call failures (transient, may retry)"],"tags":["llm","auto-categorization","provider-registry","configuration"],"backgroundTag":"llm-provider-not-configured","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}