we-promise/sure · error · StandardError
Binance credentials not configured
Error message
Binance credentials not configured
What it means
Raised by BinanceItem#import_latest_binance_data when binance_provider (from the Provided concern) returns nil, i.e. the item has no usable API credentials — credentials_configured? (api_key present AND api_secret present) is false. It is a plain StandardError, logged as "BinanceItem <id> - Failed to import: Binance credentials not configured" and re-raised, so a sync job that hits it fails visibly.
Source
Thrown at app/models/binance_item.rb:38
has_one_attached :logo, dependent: :purge_later
has_many :binance_accounts, dependent: :destroy
has_many :accounts, through: :binance_accounts
scope :active, -> { where(scheduled_for_deletion: false) }
scope :syncable, -> { active }
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 import_latest_binance_data
provider = binance_provider
unless provider
raise StandardError, "Binance credentials not configured"
end
BinanceItem::Importer.new(self, binance_provider: provider).import
rescue StandardError => e
Rails.logger.error "BinanceItem #{id} - Failed to import: #{e.message}"
raise
end
def process_accounts
Rails.logger.info "BinanceItem #{id} - process_accounts: total binance_accounts=#{binance_accounts.count}"
return [] if binance_accounts.empty?
binance_accounts.each do |ba|
Rails.logger.info(
"BinanceItem #{id} - binance_account #{ba.id}: " \
"name='#{ba.name}' " \
"account_provider=#{ba.account_provider&.id || 'nil'} " \View on GitHub (pinned to e69894adb9)
Solutions
- Set real credentials on the item: binance_item.update!(api_key: ..., api_secret: ...) — presence validations on both columns exist for exactly this reason.
- Guard scheduled syncs with credentials_configured? and skip (or mark status: requires_update) instead of letting the job raise.
- If credentials exist but read blank, check AR encryption setup: encryption_ready? gated encrypts on the columns, so a missing/changed encryption key in this environment can surface as unreadable values.
- Audit rows: BinanceItem.where(api_key: [nil, '']).or(BinanceItem.where(api_secret: [nil, ''])) to find broken items.
Example fix
# before
binance_item.import_latest_binance_data
# after
unless binance_item.credentials_configured?
Rails.logger.warn "BinanceItem #{binance_item.id} skipped: credentials missing"
next
end
binance_item.import_latest_binance_data Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, "Binance credentials missing" unless binance_item.credentials_configured? # equivalent pre-check: binance_item.api_key.present? && binance_item.api_secret.present?
Type guard
# Ruby def importable_binance_item?(item) item.is_a?(BinanceItem) && item.active? && item.credentials_configured? # active excludes scheduled_for_deletion end
Try / catch
begin
binance_item.import_latest_binance_data
rescue StandardError => e
raise unless e.message.include?("credentials not configured")
Rails.logger.warn("BinanceItem #{binance_item.id} skipped sync: credentials missing")
end Prevention
- Gate every scheduled sync on credentials_configured? and skip/mark requires_update instead of raising inside the job.
- Only create BinanceItem rows through flows that enforce the api_key/api_secret presence validations (no console/seed shortcuts).
- Verify AR encryption keys are configured in every environment — the encrypts columns can surface as unreadable values when keys are missing.
When it happens
Trigger: A sync/import job (or console call) runs import_latest_binance_data on a BinanceItem row whose api_key or api_secret is blank: created outside the normal form flow (seed, console, data import bypassing presence validations), or credentials wiped by an update — then provider construction returns nil and the guard at app/models/binance_item.rb:37-39 fires.
Common situations: Seeded/demo rows without real keys; ActiveRecord encryption misconfiguration (encrypts :api_key/:api_secret active in one env but the ciphertext unreadable/blank in another, e.g. missing encryption key in a migrated environment); partial record copies between databases.
Related errors
- IBKR credentials are missing.
- IndexaCapital provider is not configured
- BrexItem::AccountFlow::NoApiTokenError
- Trading 212 API key is missing.
- This property data provider is not configured.
AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21).
Data as JSON: /api/errors/37e9fe3f531aed15.
Report an issue: GitHub.