we-promise/sure · error · Provider::IbkrFlex::ConfigurationError

IBKR credentials are missing.

Error message

IBKR credentials are missing.

What it means

IbkrItem::Syncer#perform_sync checks credentials_configured? (query_id AND token present) before importing; on failure it first marks the item status :requires_update, then raises Provider::IbkrFlex::ConfigurationError so the sync records as failed with a specific, machine-checkable cause.

Source

Thrown at app/models/ibkr_item/syncer.rb:14

class IbkrItem::Syncer
  include SyncStats::Collector

  attr_reader :ibkr_item

  def initialize(ibkr_item)
    @ibkr_item = ibkr_item
  end

  def perform_sync(sync)
    sync.update!(status_text: "Checking IBKR credentials...") if sync.respond_to?(:status_text)
    unless ibkr_item.credentials_configured?
      ibkr_item.update!(status: :requires_update)
      raise Provider::IbkrFlex::ConfigurationError, "IBKR credentials are missing."
    end

    sync.update!(status_text: "Importing IBKR accounts...") if sync.respond_to?(:status_text)
    ibkr_item.import_latest_ibkr_data

    sync.update!(status_text: "Checking account configuration...") if sync.respond_to?(:status_text)
    collect_setup_stats(sync, provider_accounts: ibkr_item.ibkr_accounts.to_a)

    unlinked_accounts = ibkr_item.ibkr_accounts.left_joins(:account_provider).where(account_providers: { id: nil })
    linked_accounts = ibkr_item.ibkr_accounts.joins(:account).merge(Account.visible)

    if unlinked_accounts.any?
      ibkr_item.update!(pending_account_setup: true)
      sync.update!(status_text: "#{unlinked_accounts.count} IBKR account(s) need setup...") if sync.respond_to?(:status_text)
    else
      ibkr_item.update!(pending_account_setup: false)
    end

View on GitHub (pinned to e69894adb9)

Solutions

  1. Complete IBKR credential setup on the item (query_id + token); the item's requires_update status flags this in the UI
  2. Skip scheduling syncs when !item.credentials_configured? and prompt the user instead
  3. Rescue Provider::IbkrFlex::ConfigurationError in the sync job to mark the sync failed with a configuration-specific message

Example fix

begin
  IbkrItem::Syncer.new(ibkr_item).perform_sync(sync)
rescue Provider::IbkrFlex::ConfigurationError
  # item already flipped to requires_update; surface a setup prompt, not a stack trace
end
Defensive patterns

Strategy: validation

Validate before calling

ibkr_item.credentials_configured? # false => perform_sync will set status :requires_update and raise Provider::IbkrFlex::ConfigurationError

Try / catch

rescue Provider::IbkrFlex::ConfigurationError in the sync job; the item is already flagged requires_update — record the failure and prompt for setup instead of retrying

Prevention

When it happens

Trigger: A sync job running for an IbkrItem whose query_id or token is nil/blank — the user never completed credential entry, or credentials were cleared while periodic syncs were still scheduled.

Common situations: Scheduled syncs for half-configured items; credential rotation that blanked a field; items created via data import without credentials.

Related errors


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