Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle 413 responses #492

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ adheres to [Semantic Versioning](http://semver.org/).
### Added
- Support for Karafka (#480)
- Support for nested `to_honeybadger_context` (#488)
- Explain 413 responses from API (#492)

### Fixed
- `Honeybadger::Config#respond_to?` would always return true (#490)
Expand Down
3 changes: 2 additions & 1 deletion lib/honeybadger/backend/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Response
429 => "Your project is currently sending too many errors.\nThis issue should resolve itself once error traffic is reduced.".freeze,
503 => "Your project is currently sending too many errors.\nThis issue should resolve itself once error traffic is reduced.".freeze,
402 => "The project owner's billing information has expired (or the trial has ended).\nPlease check your payment details or email support@honeybadger.io for help.".freeze,
403 => "The API key is invalid. Please check your API key and try again.".freeze
403 => "The API key is invalid. Please check your API key and try again.".freeze,
413 => "The payload is too large.".freeze
}.freeze

# Initializes the Response instance.
Expand Down
2 changes: 2 additions & 0 deletions lib/honeybadger/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ def handle_response(msg, response)
when 403
warn { sprintf('Error report failed: API key is invalid. id=%s code=%s', msg.id, response.code) }
suspend(3600)
when 413
warn { sprintf('Error report failed: Payload is too large. id=%s code=%s', msg.id, response.code) }
when 201
if throttle = dec_throttle
info { sprintf('Success ⚡ https://app.honeybadger.io/notice/%s id=%s code=%s throttle=%s interval=%s', msg.id, msg.id, response.code, throttle, throttle_interval) }
Expand Down
9 changes: 9 additions & 0 deletions spec/unit/honeybadger/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ def handle_response
end
end

context "when 413" do
let(:response) { Honeybadger::Backend::Response.new(413, %({"error":"Payload exceeds maximum size"})) }

it "warns the logger" do
expect(config.logger).to receive(:warn).with(/too large/)
handle_response
end
end

context "when 201" do
let(:response) { Honeybadger::Backend::Response.new(201) }

Expand Down