we-promise/sure · error · Provider::Redbark::Error
unknown
unknown
Error message
Unexpected response #{response.code}: #{error_message_from(response)} What it means
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.
Source
Thrown at app/models/provider/redbark.rb:252
case response.code
when 200, 201
JSON.parse(response.body, symbolize_names: true)
when 400
raise Error.new("Bad request: #{error_message_from(response)}", :bad_request)
when 401
raise AuthenticationError.new("Invalid API key", :unauthorized)
when 403
raise AuthenticationError.new("Access forbidden - your Redbark plan may not include API access", :access_forbidden)
when 404
raise Error.new("Resource not found", :not_found)
when 410
raise Error.new("Endpoint requires an accountId: #{error_message_from(response)}", :bad_request)
when 429
raise RateLimitError.new("Rate limit exceeded", :rate_limited)
when 500..599
raise ServerError.new("Redbark server error (#{response.code})", :server_error)
else
raise Error.new("Unexpected response #{response.code}: #{error_message_from(response)}", :unknown)
end
end
def error_message_from(response)
parsed = JSON.parse(response.body)
parsed.dig("error", "message") || "no error message provided"
rescue JSON::ParserError
"unparseable error response"
end
end
View on GitHub (pinned to e69894adb9)
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
Example fix
# before
when 429
raise RateLimitError.new("Rate limit exceeded", :rate_limited)
# after (after confirming Redbark now returns 422 for validation)
when 422
raise Error.new("Validation failed: #{error_message_from(response)}", :bad_request) Defensive patterns
Strategy: try-catch
Type guard
def redbark_unknown_status?(error) error.is_a?(Provider::Redbark::Error) && error.error_type == :unknown end
Try / catch
begin
redbark.list_connections
rescue Provider::Redbark::Error => e
raise unless e.error_type == :unknown
Sentry.capture_exception(e, extra: { status_line: e.message }) # includes code + provider msg
raise
end Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21).
Data as JSON: /api/errors/c1a114166a4d1ef3.
Report an issue: GitHub.