we-promise/sure · error · StandardError

SnapTrade is not authorized

Error message

SnapTrade is not authorized

What it means

Error "SnapTrade is not authorized" thrown in we-promise/sure.

Source

Thrown at app/models/snaptrade_item/syncer.rb:15

class SnaptradeItem::Syncer
  include SyncStats::Collector

  attr_reader :snaptrade_item

  def initialize(snaptrade_item)
    @snaptrade_item = snaptrade_item
  end

  def perform_sync(sync)
    Rails.logger.info "SnaptradeItem::Syncer - Starting sync for item #{snaptrade_item.id}"

    # Verify the item is authorized
    unless snaptrade_item.oauth_configured?
      raise StandardError, "SnapTrade is not authorized"
    end

    # Phase 1: Import data from SnapTrade API
    sync.update!(status_text: "Importing accounts from SnapTrade...") if sync.respond_to?(:status_text)
    snaptrade_item.import_latest_snaptrade_data(sync: sync)

    # Phase 2: Collect setup statistics
    finalize_setup_counts(sync)

    # Phase 3: Process holdings and activities for linked accounts
    # Preload account_provider and account to avoid N+1 queries
    linked_snaptrade_accounts = snaptrade_item.linked_snaptrade_accounts.includes(account_provider: :account)
    if linked_snaptrade_accounts.any?
      sync.update!(status_text: "Processing holdings and activities...") if sync.respond_to?(:status_text)
      snaptrade_item.process_accounts

      # Phase 4: Schedule balance calculations
      sync.update!(status_text: "Calculating balances...") if sync.respond_to?(:status_text)

View on GitHub (pinned to e69894adb9)

When it happens

Trigger: Thrown at app/models/snaptrade_item/syncer.rb:15 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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