{"record":{"id":"c1a114166a4d1ef3","repo":"we-promise/sure","slug":"unknown-c1a114","errorCode":"unknown","errorMessage":"Unexpected response #{response.code}: #{error_message_from(response)}","messagePattern":"Unexpected response #(.+?): #(.+?)","errorType":"exception","errorClass":"Provider::Redbark::Error","httpStatus":null,"severity":"error","filePath":"app/models/provider/redbark.rb","lineNumber":252,"sourceCode":"      case response.code\n      when 200, 201\n        JSON.parse(response.body, symbolize_names: true)\n      when 400\n        raise Error.new(\"Bad request: #{error_message_from(response)}\", :bad_request)\n      when 401\n        raise AuthenticationError.new(\"Invalid API key\", :unauthorized)\n      when 403\n        raise AuthenticationError.new(\"Access forbidden - your Redbark plan may not include API access\", :access_forbidden)\n      when 404\n        raise Error.new(\"Resource not found\", :not_found)\n      when 410\n        raise Error.new(\"Endpoint requires an accountId: #{error_message_from(response)}\", :bad_request)\n      when 429\n        raise RateLimitError.new(\"Rate limit exceeded\", :rate_limited)\n      when 500..599\n        raise ServerError.new(\"Redbark server error (#{response.code})\", :server_error)\n      else\n        raise Error.new(\"Unexpected response #{response.code}: #{error_message_from(response)}\", :unknown)\n      end\n    end\n\n    def error_message_from(response)\n      parsed = JSON.parse(response.body)\n      parsed.dig(\"error\", \"message\") || \"no error message provided\"\n    rescue JSON::ParserError\n      \"unparseable error response\"\n    end\nend\n","sourceCodeStart":234,"sourceCodeEnd":263,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/provider/redbark.rb#L234-L263","documentation":"Raised by Provider::Redbark's handle_response for any status code outside its mapped set (200/201, 400, 401, 403, 404, 410, 429, 500-599) — e.g. 405, 406, 409, or 422. Error type :unknown. The message includes the raw status code and the parsed provider message, so it captures unmapped contract changes or intermediary interference.","triggerScenarios":"Redbark introducing a new status (like 422 validation responses) not yet in the case statement; a corporate proxy or gateway answering with an unusual code; API base URL pointing at something that is not the real Redbark API.","commonSituations":"API version drift after Redbark adds endpoints/validation; custom BASE_URL overrides in forks; middleboxes injecting 502/520-style codes outside the 500-599 range.","solutions":["Log response.code and the provider message, then check the Redbark changelog for new behavior","Reproduce with curl using the same key to rule out intermediaries","Extend handle_response's case statement with the observed status once identified","Verify BASE_URL has not been overridden to a nonstandard host"],"exampleFix":"# before\nwhen 429\n  raise RateLimitError.new(\"Rate limit exceeded\", :rate_limited)\n\n# after (after confirming Redbark now returns 422 for validation)\nwhen 422\n  raise Error.new(\"Validation failed: #{error_message_from(response)}\", :bad_request)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def redbark_unknown_status?(error)\n  error.is_a?(Provider::Redbark::Error) && error.error_type == :unknown\nend","tryCatchPattern":"begin\n  redbark.list_connections\nrescue Provider::Redbark::Error => e\n  raise unless e.error_type == :unknown\n  Sentry.capture_exception(e, extra: { status_line: e.message }) # includes code + provider msg\n  raise\nend","preventionTips":["Log the full status line and body for :unknown errors — they usually mean contract drift","Watch Redbark changelists after integrating; add new statuses to handle_response as they appear","Pin BASE_URL and avoid overriding it in forks so proxies can't inject odd statuses unnoticed"],"tags":["redbark","unknown-status","unmapped-response","contract-change"],"backgroundTag":"unexpected-http-status-code","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}