we-promise/sure · warning · StandardError
Enable Banking session is not valid or has expired
Error message
Enable Banking session is not valid or has expired
What it means
ArgumentError raised by validate_date_params! when validated_end_date > Date.current. The provider refuses to ask Yahoo for future quotes; prices for dates that have not closed yet do not exist. Note it compares against Date.current (server timezone), so a UTC 'today' vs app-timezone 'today' mismatch at day boundaries can trip it near midnight.
Source
Thrown at app/models/enable_banking_item.rb:197
update!(session_expires_at: parsed)
rescue ArgumentError, TypeError, ActiveRecord::ActiveRecordError => e
# Best-effort reconciliation: swallow bad timestamps (ArgumentError/TypeError)
# as well as validation/locking failures from update! (RecordInvalid,
# StaleObjectError) so a sync is never derailed by expiry bookkeeping.
Rails.logger.warn "EnableBankingItem #{id} - Failed to reconcile session expiry: #{e.message}"
end
def import_latest_enable_banking_data
provider = enable_banking_provider
unless provider
Rails.logger.error "EnableBankingItem #{id} - Cannot import: Enable Banking provider is not configured"
raise StandardError.new("Enable Banking provider is not configured")
end
unless session_valid?
Rails.logger.error "EnableBankingItem #{id} - Cannot import: Session is not valid"
update!(status: :requires_update)
raise StandardError.new("Enable Banking session is not valid or has expired")
end
EnableBankingItem::Importer.new(self, enable_banking_provider: provider).import
rescue => e
Rails.logger.error "EnableBankingItem #{id} - Failed to import data: #{e.message}"
raise
end
def process_accounts
return [] if enable_banking_accounts.empty?
results = []
enable_banking_accounts.joins(:account).merge(Account.visible).each do |enable_banking_account|
begin
result = EnableBankingAccount::Processor.new(enable_banking_account).process
results << { enable_banking_account_id: enable_banking_account.id, success: true, result: result }
rescue => e
Rails.logger.error "EnableBankingItem #{id} - Failed to process account #{enable_banking_account.id}: #{e.message}"View on GitHub (pinned to e69894adb9)
Solutions
- Clamp end_date to Date.current before calling: end_date = [end_date, Date.current].min
- Align date computation with the exchange's timezone rather than the server clock
- In UIs, disable future dates in the range picker
- If 'today' prices are wanted, request end_date = Date.current and accept the last close
Example fix
# before provider.fetch_security_prices(symbol: s, start_date: start, end_date: user_end_date) # after end_date = [user_end_date.to_date, Date.current].min provider.fetch_security_prices(symbol: s, start_date: start, end_date: end_date)
Defensive patterns
Strategy: validation
Validate before calling
end_date = [end_date.to_date, Date.current].min # never ask for future quotes
Try / catch
begin
provider.fetch_security_prices(symbol: sym, start_date: s, end_date: e)
rescue ArgumentError => e
raise unless e.message.include?("cannot be in the future")
e = Date.current
retry
end Prevention
- Clamp end_date to today at the boundary before any provider call
- Compute 'today' in the exchange's timezone for near-midnight jobs
- Disable future dates in range pickers
When it happens
Trigger: Calling fetch_security_prices with end_date = Date.tomorrow (e.g., user requests 'next 7 days' of prices); timezone skew: server in UTC late evening while app timezone already rolled to the next day; date pickers that default end_date to end-of-week inclusive of tomorrow.
Common situations: Forward-looking valuation requests (projected portfolio value); cron jobs running near UTC midnight computing 'today' differently from the app timezone; imports with exchange timezones ahead of the server.
Related errors
- Could not sync Akahu connection
- Enable Banking provider is not configured
- Import failed
- Could not sign in with that passkey. Please try again or use
- Could not save that passkey or security key. Please try agai
AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21).
Data as JSON: /api/errors/0049ece5b9b36820.
Report an issue: GitHub.