{"record":{"id":"dfbd03fa4e1c248e","repo":"we-promise/sure","slug":"network-error-dfbd03","errorCode":"network_error","errorMessage":"Network error after #{max_retries} retries: #{e.message}","messagePattern":"Network error after #(.+?) retries: #(.+?)","errorType":"exception","errorClass":"Provider::Redbark::Error","httpStatus":null,"severity":"error","filePath":"app/models/provider/redbark.rb","lineNumber":211,"sourceCode":"        yield\n      rescue *RETRYABLE_ERRORS, RateLimitError, ServerError => e\n        retries += 1\n\n        if retries <= max_retries\n          delay = calculate_retry_delay(retries)\n          Rails.logger.warn(\n            \"Redbark API: #{operation_name} failed (attempt #{retries}/#{max_retries}): \" \\\n            \"#{e.class}: #{e.message}. Retrying in #{delay}s...\"\n          )\n          sleep(delay)\n          retry\n        else\n          Rails.logger.error(\n            \"Redbark API: #{operation_name} failed after #{max_retries} retries: \" \\\n            \"#{e.class}: #{e.message}\"\n          )\n          raise e if e.is_a?(Error)\n          raise Error.new(\"Network error after #{max_retries} retries: #{e.message}\", :network_error)\n        end\n      end\n    end\n\n    def calculate_retry_delay(retry_count)\n      base_delay = INITIAL_RETRY_DELAY * (2 ** (retry_count - 1))\n      jitter = base_delay * rand * 0.25\n      [ base_delay + jitter, 30 ].min\n    end\n\n    def auth_headers\n      {\n        \"Authorization\" => \"Bearer #{@api_key}\",\n        \"Content-Type\" => \"application/json\",\n        \"Accept\" => \"application/json\"\n      }\n    end\n","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/provider/redbark.rb#L193-L229","documentation":"Raised by Provider::Redbark's with_retries after MAX_RETRIES (3) attempts on transient network exceptions (SocketError, Net::OpenTimeout, Net::ReadTimeout, ECONNRESET, ECONNREFUSED, ETIMEDOUT, EOFError). Non-Error exceptions get wrapped as Error with type :network_error; Redbark's own Error subclasses (rate limit, server error) are re-raised unchanged. Retries use exponential backoff (2s base, jitter, 30s cap), so total wait before this raise is roughly 2+4+8 seconds plus jitter.","triggerScenarios":"DNS resolution failure for api.redbark.com, connection refused, or read timeouts (default timeout 120s) persisting across all 3 retry attempts during any Redbark GET.","commonSituations":"Local network outage, corporate proxy/firewall blocking the API host, DNS misconfiguration, Redbark endpoint unreachable from the deployment region, TLS interception breaking connections.","solutions":["Verify network reachability from the app host: curl -I https://api.redbark.com/v1/accounts","Check DNS and proxy/firewall rules for api.redbark.com (and TLS interception on the path)","Retry the sync later from the caller — the library already burned its 3 retries with backoff","If timeouts dominate, review whether the 120s HTTParty timeout suits your environment before tuning anything else"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"require \"socket\"\nrequire \"resolv\"\n\ndef redbark_reachable?(host = \"api.redbark.com\")\n  Resolv::DNS.open { |dns| !dns.getresources(host, Resolv::DNS::Resource::IN::A).empty? }\nrescue SocketError\n  false\nend","typeGuard":"def redbark_network_error?(error)\n  error.is_a?(Provider::Redbark::Error) && error.error_type == :network_error\nend","tryCatchPattern":"begin\n  redbark.list_accounts\nrescue Provider::Redbark::Error => e\n  raise unless e.error_type == :network_error\n  RedbarkSyncJob.perform_in(30.minutes, user.id) # outer backoff; library already retried 3x\nend","preventionTips":["Monitor egress to api.redbark.com from the app host (DNS, proxy, firewall) before shipping sync jobs","Don't add tight caller-side retries on top — the library already did 3 attempts with exponential backoff","Distinguish :network_error from RateLimitError/ServerError in handlers so outages don't get treated as throttling"],"tags":["redbark","network","timeout","retries-exhausted","httparty"],"backgroundTag":"network-error-retries-exhausted","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}