we-promise/sure · error · StandardError
IBKR provider is not configured
Error message
IBKR provider is not configured
What it means
IbkrItem#import_latest_ibkr_data raises StandardError('IBKR provider is not configured') when ibkr_provider returns nil. credentials_configured? (app/models/ibkr_item.rb:31) requires BOTH query_id and token to be present; the provided concern returns a nil provider when either is missing, and the import refuses to run.
Source
Thrown at app/models/ibkr_item.rb:37
validates :token, presence: true, on: :create
scope :active, -> { where(scheduled_for_deletion: false) }
scope :syncable, -> { active.where.not(query_id: [ nil, "" ]).where.not(token: nil) }
scope :ordered, -> { order(created_at: :desc) }
scope :needs_update, -> { where(status: :requires_update) }
def destroy_later
update!(scheduled_for_deletion: true)
DestroyJob.perform_later(self)
end
def credentials_configured?
query_id.present? && token.present?
end
def import_latest_ibkr_data
provider = ibkr_provider
raise StandardError, "IBKR provider is not configured" unless provider
IbkrItem::Importer.new(self, ibkr_provider: provider).import
rescue => e
Rails.logger.error("IbkrItem #{id} - Failed to import data: #{e.message}")
raise
end
def process_accounts
return [] if ibkr_accounts.empty?
linked_ibkr_accounts.includes(account_provider: :account).each_with_object([]) do |ibkr_account, results|
account = ibkr_account.current_account
next unless account
next if account.pending_deletion? || account.disabled?
begin
result = IbkrAccount::Processor.new(ibkr_account).process
results << { ibkr_account_id: ibkr_account.id, success: true, result: result }View on GitHub (pinned to e69894adb9)
Solutions
- Set both fields: ibkr_item.update!(query_id: <Flex Query ID>, token: <IBKR token>) and retry
- Guard with ibkr_item.credentials_configured? before importing; IbkrItem::Syncer#perform_sync already does this and sets status :requires_update
- Prefer the syncer path and rescue Provider::IbkrFlex::ConfigurationError rather than calling import_latest_ibkr_data unguarded
Example fix
// before ibkr_item.import_latest_ibkr_data // after raise ArgumentError, 'IBKR item needs query_id and token' unless ibkr_item.credentials_configured? ibkr_item.import_latest_ibkr_data
Defensive patterns
Strategy: validation
Validate before calling
ibkr_item.credentials_configured? # query_id.present? && token.present? — false means import will raise
Try / catch
rescue StandardError around import_latest_ibkr_data (the method already logs 'Failed to import data: ...' with the item id before re-raising); map the 'not configured' message to a setup-required state
Prevention
- Require both query_id and token before an IbkrItem becomes syncable
- Prefer IbkrItem::Syncer, which converts missing credentials into status :requires_update + Provider::IbkrFlex::ConfigurationError
- Block scheduled syncs for items lacking credentials
When it happens
Trigger: Calling import_latest_ibkr_data (directly or via a sync flow) on an IbkrItem whose query_id or token is nil/blank — an item created but never fully credentialed, or one field cleared later.
Common situations: Setup flows that enqueue import before credential entry; scheduled jobs for half-configured items; data copied between environments with blank credential columns.
Related errors
- IBKR credentials are missing.
- invalid_access_key
- unauthorized
- Binance credentials not configured
- Brex transaction missing required field 'id'
AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21).
Data as JSON: /api/errors/2ced2124d740ed32.
Report an issue: GitHub.