we-promise/sure · error · StandardError

IndexaCapital provider is not configured

Error message

IndexaCapital provider is not configured

What it means

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.

Source

Thrown at app/models/indexa_capital_item.rb:56

    IndexaCapitalItem::Syncer.new(self)
  end

  def destroy_later
    update!(scheduled_for_deletion: true)
    DestroyJob.perform_later(self)
  end

  # Override syncing? to include background activities fetch
  def syncing?
    super || indexa_capital_accounts.where(activities_fetch_pending: true).exists?
  end

  # Import data from provider API
  def import_latest_indexa_capital_data(sync: nil)
    provider = indexa_capital_provider
    unless provider
      Rails.logger.error "IndexaCapitalItem #{id} - Cannot import: provider is not configured"
      raise StandardError, I18n.t("indexa_capital_items.errors.provider_not_configured")
    end

    IndexaCapitalItem::Importer.new(self, indexa_capital_provider: provider, sync: sync).import
  rescue => e
    Rails.logger.error "IndexaCapitalItem #{id} - Failed to import data: #{e.message}"
    raise
  end

  # Process linked accounts after data import
  def process_accounts
    return [] if indexa_capital_accounts.empty?

    results = []
    linked_indexa_capital_accounts.includes(account_provider: :account).each do |indexa_capital_account|
      begin
        result = IndexaCapitalAccount::Processor.new(indexa_capital_account).process
        results << { indexa_capital_account_id: indexa_capital_account.id, success: true, result: result }
      rescue => e

View on GitHub (pinned to e69894adb9)

Solutions

  1. Set ENV['INDEXA_API_TOKEN'] for the process (and restart it), or store an api_token on the IndexaCapitalItem.
  2. Otherwise fill in all three of username, document, and password on the item.
  3. Guard callers: skip or reschedule when item.credentials_configured? is false.
  4. Check the IndexaCapitalItem row (username/document/password/api_token presence) for the failing id in the log line.

Example fix

# before
item.import_latest_indexa_capital_data

# after
if item.credentials_configured?
  item.import_latest_indexa_capital_data
else
  Rails.logger.warn "Skipping IndexaCapitalItem #{item.id}: credentials missing"
end
Defensive patterns

Strategy: validation

Validate before calling

item.credentials_configured? # IndexaCapitalItem::Provided — token OR username+document+password

Try / catch

begin
  item.import_latest_indexa_capital_data
rescue StandardError => e
  notify_user(item, e.message) if e.message =~ /not configured/i
  raise
end

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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