{"record":{"id":"500be56e014a9beb","repo":"we-promise/sure","slug":"snaptrade-is-not-authorized-500be5","errorCode":null,"errorMessage":"SnapTrade is not authorized","messagePattern":"SnapTrade is not authorized","errorType":"exception","errorClass":"StandardError","httpStatus":null,"severity":"error","filePath":"app/models/snaptrade_item/syncer.rb","lineNumber":15,"sourceCode":"class SnaptradeItem::Syncer\n  include SyncStats::Collector\n\n  attr_reader :snaptrade_item\n\n  def initialize(snaptrade_item)\n    @snaptrade_item = snaptrade_item\n  end\n\n  def perform_sync(sync)\n    Rails.logger.info \"SnaptradeItem::Syncer - Starting sync for item #{snaptrade_item.id}\"\n\n    # Verify the item is authorized\n    unless snaptrade_item.oauth_configured?\n      raise StandardError, \"SnapTrade is not authorized\"\n    end\n\n    # Phase 1: Import data from SnapTrade API\n    sync.update!(status_text: \"Importing accounts from SnapTrade...\") if sync.respond_to?(:status_text)\n    snaptrade_item.import_latest_snaptrade_data(sync: sync)\n\n    # Phase 2: Collect setup statistics\n    finalize_setup_counts(sync)\n\n    # Phase 3: Process holdings and activities for linked accounts\n    # Preload account_provider and account to avoid N+1 queries\n    linked_snaptrade_accounts = snaptrade_item.linked_snaptrade_accounts.includes(account_provider: :account)\n    if linked_snaptrade_accounts.any?\n      sync.update!(status_text: \"Processing holdings and activities...\") if sync.respond_to?(:status_text)\n      snaptrade_item.process_accounts\n\n      # Phase 4: Schedule balance calculations\n      sync.update!(status_text: \"Calculating balances...\") if sync.respond_to?(:status_text)","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/snaptrade_item/syncer.rb#L1-L33","documentation":"Error \"SnapTrade is not authorized\" thrown in we-promise/sure.","triggerScenarios":"Thrown at app/models/snaptrade_item/syncer.rb:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}