we-promise/sure · warning · StandardError
Enable Banking provider is not configured
Error message
Enable Banking provider is not configured
What it means
ArgumentError raised by validate_date_params! (called at the top of fetch_security_prices, app/models/provider/yahoo_finance.rb:327) when the coerced start_date falls after end_date. Unlike the Error variant at line 638, this fires on the prices path after both values have passed validate_and_coerce_date! (presence + coercion), so the values are real Dates in the wrong order. No HTTP request is made.
Source
Thrown at app/models/enable_banking_item.rb:191
valid_until = session_data.dig(:access, :valid_until) || session_data.dig("access", "valid_until")
return if valid_until.blank?
parsed = Time.zone.parse(valid_until.to_s)
return if parsed.nil? || parsed == session_expires_at
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 = []View on GitHub (pinned to e69894adb9)
Solutions
- Swap the arguments at the call site; confirm start_date <= end_date after to_date coercion
- If you only have a single date, mimic the internal pattern: start_date = date - 10.days, end_date = date
- Add an assertion/guard in the calling service before invoking the provider
- Cover with a unit test on reversed arguments
Example fix
# before provider.fetch_security_prices(symbol: s, start_date: Date.today, end_date: Date.today - 30) # after provider.fetch_security_prices(symbol: s, start_date: Date.today - 30, end_date: Date.today)
Defensive patterns
Strategy: validation
Validate before calling
s = start_date.to_date
e = end_date.to_date
raise ArgumentError, "start_date #{s} after end_date #{e}" if s > e 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 after end date")
s, e = [s, e].minmax
retry
end Prevention
- Derive start_date from the target date with subtraction (date - N.days), never addition
- Coerce all date params with to_date before comparison to avoid Time precision surprises
- Validate ranges once at the service layer, not ad hoc in every caller
When it happens
Trigger: Calling fetch_security_prices(start_date:, end_date:) with reversed dates; passing strings like '2024-13-01' that coerce surprisingly; a caller computing start = date + 10.days by mistake instead of date - 10.days (as fetch_security_price itself does correctly at line 296).
Common situations: Date math sign errors in backfill jobs; form fields wired backwards; inclusive/exclusive boundary confusion at DST changes when using DateTime.
Related errors
- Could not sync Akahu connection
- Enable Banking session is not valid or has expired
- 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/e7b494b7166bfb9f.
Report an issue: GitHub.