Skip to content

Add Puma cluster mode and fix webhook/error-reporting bugs#92

Merged
mensfeld merged 2 commits into
masterfrom
fix/webhook-encoding-and-error-subscriber-args
Jul 7, 2026
Merged

Add Puma cluster mode and fix webhook/error-reporting bugs#92
mensfeld merged 2 commits into
masterfrom
fix/webhook-encoding-and-error-subscriber-args

Conversation

@mensfeld

@mensfeld mensfeld commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Boot Puma in cluster mode with 3 workers by default (WEB_CONCURRENCY, config/puma.rb) instead of a single process.
  • Fix Encoding::UndefinedConversionError 500s in Webhooks::ReceiveController#create: raw request bodies/headers come back ASCII-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 and scrubbed before being persisted.
  • Fix Admin::Errors::Subscriber silently failing to queue error-capture jobs (Unsupported argument type: ...Controller): Rails' automatic error context puts the live controller instance under context[:controller], which isn't ActiveJob-serializable. Now it's reduced to the class name, and a general sanitize pass protects additional context from any other stray non-primitive object.

Test plan

  • bundle exec rspec spec/services/admin/errors/subscriber_spec.rb
  • bundle exec rspec spec/controllers/webhooks (or wherever the webhook controller spec lives)
  • Manually POST a webhook payload containing non-ASCII text (e.g. an em dash) and confirm it's stored instead of 500ing
  • Confirm Puma boots with 3 worker processes (ps or pumactl status)

- 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.
@mensfeld mensfeld self-assigned this Jul 7, 2026
…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.
@mensfeld mensfeld added the bug Something isn't working label Jul 7, 2026
@mensfeld
mensfeld merged commit f1b8567 into master Jul 7, 2026
6 checks passed
@mensfeld
mensfeld deleted the fix/webhook-encoding-and-error-subscriber-args branch July 7, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant