{"record":{"id":"e7b494b7166bfb9f","repo":"we-promise/sure","slug":"enable-banking-provider-is-not-configured","errorCode":null,"errorMessage":"Enable Banking provider is not configured","messagePattern":"Enable Banking provider is not configured","errorType":"exception","errorClass":"StandardError","httpStatus":null,"severity":"warning","filePath":"app/models/enable_banking_item.rb","lineNumber":191,"sourceCode":"    valid_until = session_data.dig(:access, :valid_until) || session_data.dig(\"access\", \"valid_until\")\n    return if valid_until.blank?\n\n    parsed = Time.zone.parse(valid_until.to_s)\n    return if parsed.nil? || parsed == session_expires_at\n\n    update!(session_expires_at: parsed)\n  rescue ArgumentError, TypeError, ActiveRecord::ActiveRecordError => e\n    # Best-effort reconciliation: swallow bad timestamps (ArgumentError/TypeError)\n    # as well as validation/locking failures from update! (RecordInvalid,\n    # StaleObjectError) so a sync is never derailed by expiry bookkeeping.\n    Rails.logger.warn \"EnableBankingItem #{id} - Failed to reconcile session expiry: #{e.message}\"\n  end\n\n  def import_latest_enable_banking_data\n    provider = enable_banking_provider\n    unless provider\n      Rails.logger.error \"EnableBankingItem #{id} - Cannot import: Enable Banking provider is not configured\"\n      raise StandardError.new(\"Enable Banking provider is not configured\")\n    end\n\n    unless session_valid?\n      Rails.logger.error \"EnableBankingItem #{id} - Cannot import: Session is not valid\"\n      update!(status: :requires_update)\n      raise StandardError.new(\"Enable Banking session is not valid or has expired\")\n    end\n\n    EnableBankingItem::Importer.new(self, enable_banking_provider: provider).import\n  rescue => e\n    Rails.logger.error \"EnableBankingItem #{id} - Failed to import data: #{e.message}\"\n    raise\n  end\n\n  def process_accounts\n    return [] if enable_banking_accounts.empty?\n\n    results = []","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/enable_banking_item.rb#L173-L209","documentation":"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.","triggerScenarios":"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).","commonSituations":"Date math sign errors in backfill jobs; form fields wired backwards; inclusive/exclusive boundary confusion at DST changes when using DateTime.","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"],"exampleFix":"# before\nprovider.fetch_security_prices(symbol: s, start_date: Date.today, end_date: Date.today - 30)\n\n# after\nprovider.fetch_security_prices(symbol: s, start_date: Date.today - 30, end_date: Date.today)","handlingStrategy":"validation","validationCode":"s = start_date.to_date\ne = end_date.to_date\nraise ArgumentError, \"start_date #{s} after end_date #{e}\" if s > e","typeGuard":null,"tryCatchPattern":"begin\n  provider.fetch_security_prices(symbol: sym, start_date: s, end_date: e)\nrescue ArgumentError => e\n  raise unless e.message.include?(\"cannot be after end date\")\n  s, e = [s, e].minmax\n  retry\nend","preventionTips":["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"],"tags":["yahoo-finance","date-validation","argumenterror","argument-order"],"backgroundTag":"invalid-date-range","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}