{"record":{"id":"5a570decea485ad0","repo":"we-promise/sure","slug":"ibkr-credentials-are-missing","errorCode":null,"errorMessage":"IBKR credentials are missing.","messagePattern":"IBKR credentials are missing\\.","errorType":"exception","errorClass":"Provider::IbkrFlex::ConfigurationError","httpStatus":null,"severity":"error","filePath":"app/models/ibkr_item/syncer.rb","lineNumber":14,"sourceCode":"class IbkrItem::Syncer\n  include SyncStats::Collector\n\n  attr_reader :ibkr_item\n\n  def initialize(ibkr_item)\n    @ibkr_item = ibkr_item\n  end\n\n  def perform_sync(sync)\n    sync.update!(status_text: \"Checking IBKR credentials...\") if sync.respond_to?(:status_text)\n    unless ibkr_item.credentials_configured?\n      ibkr_item.update!(status: :requires_update)\n      raise Provider::IbkrFlex::ConfigurationError, \"IBKR credentials are missing.\"\n    end\n\n    sync.update!(status_text: \"Importing IBKR accounts...\") if sync.respond_to?(:status_text)\n    ibkr_item.import_latest_ibkr_data\n\n    sync.update!(status_text: \"Checking account configuration...\") if sync.respond_to?(:status_text)\n    collect_setup_stats(sync, provider_accounts: ibkr_item.ibkr_accounts.to_a)\n\n    unlinked_accounts = ibkr_item.ibkr_accounts.left_joins(:account_provider).where(account_providers: { id: nil })\n    linked_accounts = ibkr_item.ibkr_accounts.joins(:account).merge(Account.visible)\n\n    if unlinked_accounts.any?\n      ibkr_item.update!(pending_account_setup: true)\n      sync.update!(status_text: \"#{unlinked_accounts.count} IBKR account(s) need setup...\") if sync.respond_to?(:status_text)\n    else\n      ibkr_item.update!(pending_account_setup: false)\n    end\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/ibkr_item/syncer.rb#L1-L32","documentation":"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.","triggerScenarios":"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.","commonSituations":"Scheduled syncs for half-configured items; credential rotation that blanked a field; items created via data import without credentials.","solutions":["Complete IBKR credential setup on the item (query_id + token); the item's requires_update status flags this in the UI","Skip scheduling syncs when !item.credentials_configured? and prompt the user instead","Rescue Provider::IbkrFlex::ConfigurationError in the sync job to mark the sync failed with a configuration-specific message"],"exampleFix":"begin\n  IbkrItem::Syncer.new(ibkr_item).perform_sync(sync)\nrescue Provider::IbkrFlex::ConfigurationError\n  # item already flipped to requires_update; surface a setup prompt, not a stack trace\nend","handlingStrategy":"validation","validationCode":"ibkr_item.credentials_configured? # false => perform_sync will set status :requires_update and raise Provider::IbkrFlex::ConfigurationError","typeGuard":null,"tryCatchPattern":"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","preventionTips":["Don't schedule recurring syncs until credentials_configured? is true","Monitor items in requires_update status as a setup-funnel signal","Treat this error class as permanent (configuration) — exclude it from automatic retry policies"],"tags":["ibkr","credentials","sync","configuration"],"backgroundTag":"missing-credentials","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}