Add Puma cluster mode and fix webhook/error-reporting bugs#92
Merged
Conversation
- config/puma.rb: boot 3 workers by default (WEB_CONCURRENCY) instead of single-process mode. - Webhooks::ReceiveController: force raw request bodies/headers to valid UTF-8 (scrubbing invalid bytes) before persisting, fixing Encoding::UndefinedConversionError 500s on payloads containing multi-byte UTF-8 (e.g. em dashes, smart quotes) in the raw ASCII-8BIT request body. - Admin::Errors::Subscriber: stop passing the live controller instance (and other raw objects from Rails' automatic error context) as ActiveJob arguments, which ActiveJob can't serialize and was silently breaking error capture for every unhandled controller exception.
…on fixes - Add space-inside-brackets on PRIMITIVE_TYPES per rubocop-rails-omakase style. - Add request specs reproducing the reported Encoding::UndefinedConversionError: a payload with valid multi-byte UTF-8 (em dash) and one with genuinely invalid UTF-8 bytes, verifying the webhook is stored instead of 500ing. - Add subscriber specs verifying a live controller instance in the error context is serializable as ActiveJob arguments (reproducing the "Unsupported argument type" failure) and that nested non-primitive values in additional context get stringified.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WEB_CONCURRENCY,config/puma.rb) instead of a single process.Encoding::UndefinedConversionError500s inWebhooks::ReceiveController#create: raw request bodies/headers come backASCII-8BIT-tagged, and strict transcoding to UTF-8 raised on any multi-byte sequence (e.g. an em dash or smart quote in a webhook payload). Now the body/headers are force-encoded andscrubbed before being persisted.Admin::Errors::Subscribersilently failing to queue error-capture jobs (Unsupported argument type: ...Controller): Rails' automatic error context puts the live controller instance undercontext[:controller], which isn't ActiveJob-serializable. Now it's reduced to the class name, and a generalsanitizepass protectsadditionalcontext from any other stray non-primitive object.Test plan
bundle exec rspec spec/services/admin/errors/subscriber_spec.rbbundle exec rspec spec/controllers/webhooks(or wherever the webhook controller spec lives)psorpumactl status)