{"record":{"id":"40097490112bc8b7","repo":"we-promise/sure","slug":"indexacapital-provider-is-not-configured","errorCode":null,"errorMessage":"IndexaCapital provider is not configured","messagePattern":"IndexaCapital provider is not configured","errorType":"exception","errorClass":"StandardError","httpStatus":null,"severity":"error","filePath":"app/models/indexa_capital_item.rb","lineNumber":56,"sourceCode":"    IndexaCapitalItem::Syncer.new(self)\n  end\n\n  def destroy_later\n    update!(scheduled_for_deletion: true)\n    DestroyJob.perform_later(self)\n  end\n\n  # Override syncing? to include background activities fetch\n  def syncing?\n    super || indexa_capital_accounts.where(activities_fetch_pending: true).exists?\n  end\n\n  # Import data from provider API\n  def import_latest_indexa_capital_data(sync: nil)\n    provider = indexa_capital_provider\n    unless provider\n      Rails.logger.error \"IndexaCapitalItem #{id} - Cannot import: provider is not configured\"\n      raise StandardError, I18n.t(\"indexa_capital_items.errors.provider_not_configured\")\n    end\n\n    IndexaCapitalItem::Importer.new(self, indexa_capital_provider: provider, sync: sync).import\n  rescue => e\n    Rails.logger.error \"IndexaCapitalItem #{id} - Failed to import data: #{e.message}\"\n    raise\n  end\n\n  # Process linked accounts after data import\n  def process_accounts\n    return [] if indexa_capital_accounts.empty?\n\n    results = []\n    linked_indexa_capital_accounts.includes(account_provider: :account).each do |indexa_capital_account|\n      begin\n        result = IndexaCapitalAccount::Processor.new(indexa_capital_account).process\n        results << { indexa_capital_account_id: indexa_capital_account.id, success: true, result: result }\n      rescue => e","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/indexa_capital_item.rb#L38-L74","documentation":"IndexaCapitalItem#import_latest_indexa_capital_data raises StandardError (message from I18n indexa_capital_items.errors.provider_not_configured) when indexa_capital_provider returns nil. The provider is nil unless credentials_configured? is true: either a stored/ENV api_token (api_token attribute or INDEXA_API_TOKEN) is present, or username + document + password are all present. The error is logged before raising, then re-raised after the importer runs.","triggerScenarios":"Calling import_latest_indexa_capital_data on an item whose api_token attribute is blank and INDEXA_API_TOKEN env is unset; an item created with only a username (missing document or password); credentials wiped/rotated after a security update; ENV var missing in a new deploy environment.","commonSituations":"Forgetting INDEXA_API_TOKEN in docker/cron/production env; partial manual-entry of credentials in the settings UI; test fixtures without credentials; scheduled sync job running before the user finished setup.","solutions":["Set ENV['INDEXA_API_TOKEN'] for the process (and restart it), or store an api_token on the IndexaCapitalItem.","Otherwise fill in all three of username, document, and password on the item.","Guard callers: skip or reschedule when item.credentials_configured? is false.","Check the IndexaCapitalItem row (username/document/password/api_token presence) for the failing id in the log line."],"exampleFix":"# before\nitem.import_latest_indexa_capital_data\n\n# after\nif item.credentials_configured?\n  item.import_latest_indexa_capital_data\nelse\n  Rails.logger.warn \"Skipping IndexaCapitalItem #{item.id}: credentials missing\"\nend","handlingStrategy":"validation","validationCode":"item.credentials_configured? # IndexaCapitalItem::Provided — token OR username+document+password","typeGuard":null,"tryCatchPattern":"begin\n  item.import_latest_indexa_capital_data\nrescue StandardError => e\n  notify_user(item, e.message) if e.message =~ /not configured/i\n  raise\nend","preventionTips":["Set INDEXA_API_TOKEN (or full username/document/password) in every environment that runs syncs.","Gate scheduled sync jobs on item.credentials_configured?.","Surface a 'finish setup' state in the UI instead of letting a half-configured item sync."],"tags":["provider","indexa-capital","credentials","configuration","rails"],"backgroundTag":"provider-credentials-missing","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}