{"record":{"id":"ac52bf976f1ab274","repo":"we-promise/sure","slug":"snaptrade-server-error-response-status-pleas","errorCode":null,"errorMessage":"SnapTrade server error (#{response.status}). Please try again later.","messagePattern":"SnapTrade server error \\(#(.+?)\\)\\. Please try again later\\.","errorType":"exception","errorClass":"Provider::Snaptrade::ApiError","httpStatus":null,"severity":"error","filePath":"app/models/provider/snaptrade.rb","lineNumber":392,"sourceCode":"      if response.success?\n        return {} if response.body.blank?\n        begin\n          JSON.parse(response.body)\n        rescue JSON::ParserError\n          raise ApiError.new(\"SnapTrade API error (#{operation}): invalid JSON response\",\n                             status_code: response.status, response_body: response.body)\n        end\n      else\n        Rails.logger.error(\"SnapTrade API error (#{operation}): #{response.status}\")\n        case response.status\n        when 401, 403\n          mark_requires_update!\n          raise AuthenticationError, \"Authentication failed (#{operation}): HTTP #{response.status}\"\n        when 429\n          raise ApiError.new(\"Rate limit exceeded. Please try again later.\",\n                             status_code: response.status, response_body: response.body)\n        when 500..599\n          raise ApiError.new(\"SnapTrade server error (#{response.status}). Please try again later.\",\n                             status_code: response.status, response_body: response.body)\n        else\n          raise ApiError.new(\"SnapTrade API error (#{operation}): HTTP #{response.status}\",\n                             status_code: response.status, response_body: response.body)\n        end\n      end\n    end\n\n    def api_connection\n      @api_connection ||= Faraday.new do |faraday|\n        faraday.options.timeout = 30\n        faraday.options.open_timeout = 10\n      end\n    end\n\n    def with_retries(operation_name, max_retries: MAX_RETRIES)\n      retries = 0\n","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/provider/snaptrade.rb#L374-L410","documentation":"Raised by Provider::Snaptrade.handle_response when the SnapTrade API answers HTTP 5xx. The message includes the exact status; the ApiError carries status_code and response_body. Like the SimpleFIN counterpart, this means the request reached SnapTrade and its server failed - transient upstream trouble, not an app bug.","triggerScenarios":"Any SnapTrade API call returning 500/502/503/504 - commonly during broker outages behind SnapTrade (the upstream institution's API failing), SnapTrade deployments, or overload during market-open traffic spikes.","commonSituations":"Weekend maintenance windows; a specific brokerage integration inside SnapTrade failing so only that institution's accounts error; retrying after a few minutes succeeds; correlates with SnapTrade status incidents.","solutions":["Retry later with backoff - most 5xx from SnapTrade resolve within minutes","Check the response_body on the error and the SnapTrade status page for an incident","If only one account errors while others sync, the underlying broker (not SnapTrade-wide) is the problem - still just wait","Keep the previous snapshot and surface 'sync temporarily unavailable' rather than failing hard"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  snaptrade.get_balances(account_id: id)\nrescue Provider::Snaptrade::ApiError => e\n  if (500..599).cover?(e.status_code.to_i)\n    schedule_retry(minutes: 15) # upstream transient; keep last snapshot\n  else\n    raise\n  end\nend","preventionTips":["Branch on e.status_code ranges instead of message matching","Show 'sync temporarily unavailable' UI rather than wiping data on 5xx","Correlate spikes of this error with SnapTrade status incidents before debugging locally"],"tags":["snaptrade","http-5xx","upstream","broker-outage"],"backgroundTag":"http-5xx-server-error","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}