{"record":{"id":"226e1ce5ba82ab03","repo":"we-promise/sure","slug":"failed-to-authenticate-with-yahoo-finance-e-mes","errorCode":null,"errorMessage":"Failed to authenticate with Yahoo Finance: #{e.message}","messagePattern":"Failed to authenticate with Yahoo Finance: #(.+?)","errorType":"exception","errorClass":"Provider::YahooFinance::AuthenticationError","httpStatus":null,"severity":"error","filePath":"app/models/provider/yahoo_finance.rb","lineNumber":884,"sourceCode":"      cache_key = \"#{@cache_prefix}_auth_crumb\"\n      cached = Rails.cache.read(cache_key)\n      if cached.present?\n        return cached if valid_crumb?(cached.second)\n\n        Rails.cache.delete(cache_key)\n      end\n\n      cookie, crumb, cache_duration = request_cookie_and_crumb(auth_client)\n      result = [ cookie, crumb ]\n      Rails.cache.write(cache_key, result, expires_in: cache_duration)\n      result\n    rescue Faraday::TooManyRequestsError => e\n      raise RateLimitError.new(\n        \"Yahoo Finance rate limit exceeded\",\n        details: { status: e.response&.dig(:status) }\n      )\n    rescue Faraday::Error => e\n      raise AuthenticationError, \"Failed to authenticate with Yahoo Finance: #{e.message}\"\n    end\n\n    def request_cookie_and_crumb(authentication_client)\n      cookie_response = authentication_client.get(\"https://fc.yahoo.com\")\n      if cookie_response.respond_to?(:status) && cookie_response.status == 429\n        raise RateLimitError.new(\n          \"Yahoo Finance rate limit exceeded\",\n          details: { status: cookie_response.status }\n        )\n      end\n\n      cookie = extract_cookie(cookie_response)\n      cookie_max_age = extract_cookie_max_age(cookie_response)\n      raise AuthenticationError, \"Failed to obtain Yahoo Finance cookie\" if cookie.blank?\n\n      crumb_response = authentication_client.get(\"#{base_url}/v1/test/getcrumb\") do |req|\n        req.headers[\"Cookie\"] = cookie\n      end","sourceCodeStart":866,"sourceCodeEnd":902,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/provider/yahoo_finance.rb#L866-L902","documentation":"Error \"Failed to authenticate with Yahoo Finance: #{e.message}\" thrown in we-promise/sure.","triggerScenarios":"Thrown at app/models/provider/yahoo_finance.rb:884 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}