Module: PromptSanitizer::Integrations::ActiveJobConcern

Extended by:
ActiveSupport::Concern
Defined in:
lib/prompt_sanitizer/integrations/active_job.rb

Overview

ActiveJob concern — sanitize job arguments before the job is enqueued.

Prevents PII from leaking into job queues (Sidekiq, Resque, GoodJob, etc.) where job arguments are serialized and often stored in plain text.

Usage

class SummarizeJob < ApplicationJob
include PromptSanitizer::Integrations::ActiveJobConcern
sanitize_argument :prompt

def perform(prompt:)
  # `prompt` is already sanitized here
  call_llm(prompt)
end
end

How it works

sanitize_argument registers an around_perform callback that sanitizes the named keyword argument(s) before perform is called and restores them in the job's return context if needed.

The original PII never touches the queue backend — the redacted version is enqueued and the job works with sanitized text.

Instance Method Summary collapse

Instance Method Details

#sanitize_pii(text) ⇒ String

Manually sanitize a string using the global sanitizer.

Parameters:

Returns:

  • sanitized text



74
75
76
# File 'lib/prompt_sanitizer/integrations/active_job.rb', line 74

def sanitize_pii(text)
  PromptSanitizer.sanitizer.sanitize(text).text
end