we-promise/sure · error · StandardError
Mercury provider is not configured
Error message
Mercury provider is not configured
What it means
AuthenticationError raised inside request_cookie_and_crumb when the GET to https://fc.yahoo.com returns a response whose Set-Cookie cannot be extracted (extract_cookie returns blank). fc.yahoo.com is the canonical trick to obtain the session cookie; if Yahoo returns an error page, a redirect without cookies, or a consent wall, there is no cookie to authorize the subsequent getcrumb call, so auth cannot proceed. The 429 case is converted to RateLimitError before this check.
Source
Thrown at app/models/mercury_item.rb:47
scope :active, -> { where(scheduled_for_deletion: false) }
scope :syncable, -> { active }
scope :ordered, -> { order(created_at: :desc) }
scope :needs_update, -> { where(status: :requires_update) }
def destroy_later
update!(scheduled_for_deletion: true)
DestroyJob.perform_later(self)
end
# TODO: Implement data import from provider API
# This method should fetch the latest data from the provider and import it.
# May need provider-specific validation (e.g., session validity checks).
# See LunchflowItem#import_latest_lunchflow_data or EnableBankingItem#import_latest_enable_banking_data for examples.
def import_latest_mercury_data
provider = mercury_provider
unless provider
Rails.logger.error "MercuryItem #{id} - Cannot import: provider is not configured"
raise StandardError.new("Mercury provider is not configured")
end
# TODO: Add any provider-specific validation here (e.g., session checks)
MercuryItem::Importer.new(self, mercury_provider: provider).import
rescue => e
Rails.logger.error "MercuryItem #{id} - Failed to import data: #{e.message}"
raise
end
# TODO: Implement account processing logic
# This method processes linked accounts after data import.
# Customize based on your provider's data structure and processing needs.
def process_accounts
return [] if mercury_accounts.empty?
results = []
mercury_accounts.joins(:account).merge(Account.visible).each do |mercury_account|
beginView on GitHub (pinned to e69894adb9)
Solutions
- Inspect the fc.yahoo.com response status and headers from the same host: curl -vI https://fc.yahoo.com | grep -i set-cookie
- If 429s precede it, wait — rate limiting often degrades into cookie-less responses
- Disable/adjust proxy or middleware that strips Set-Cookie
- Retry later; transient Yahoo cookie-flow failures usually clear
- If permanent, switch securities lookups to an alternative configured provider
Example fix
# before
cookie = extract_cookie(cookie_response)
raise AuthenticationError, "Failed to obtain Yahoo Finance cookie" if cookie.blank?
# after (diagnose before failing)
cookie = extract_cookie(cookie_response)
if cookie.blank?
Rails.logger.error("fc.yahoo.com status=#{cookie_response.status} headers=#{cookie_response.headers['Set-Cookie'].inspect}")
raise AuthenticationError, "Failed to obtain Yahoo Finance cookie"
end Defensive patterns
Strategy: retry
Try / catch
tries = 0
begin
tries += 1
provider.fetch_security_prices(symbol: s, start_date: a, end_date: b)
rescue Provider::YahooFinance::AuthenticationError => e
raise unless e.message.include?("cookie") && tries < 3
sleep(60)
retry
end Prevention
- Rate-limit cookie bootstraps — repeated fc.yahoo.com hits from flagged IPs yield cookie-less responses
- Avoid proxies/middleware that strip Set-Cookie
- Cache the cookie/crumb pair for its extracted max-age instead of refetching per call
- Monitor for Yahoo cookie-flow changes (they have historically altered fc.yahoo.com behavior)
When it happens
Trigger: fc.yahoo.com responding 404/redirect without Set-Cookie (Yahoo has changed this behavior before); an intermediary proxy stripping Set-Cookie headers; Yahoo serving a consent/CAPTCHA page to your IP; cookie name changes making extract_cookie's parsing return nil.
Common situations: Datacenter IPs flagged by Yahoo; corporate proxies rewriting responses; Yahoo A/B changes to the cookie flow; Faraday middleware (e.g., aggressive cookie jar or redirect follower) consuming headers before extraction.
Related errors
- invalid_import_record
- Failed to obtain Yahoo Finance crumb
- Lunchflow provider is not configured
- Yahoo Finance authentication failed after crumb refresh
- Could not sign in with that passkey. Please try again or use
AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21).
Data as JSON: /api/errors/229293bb753d1b95.
Report an issue: GitHub.