we-promise/sure · critical · ImportSession::EnqueueError
import_enqueue_failed
import_enqueue_failed
Error message
Import session could not be queued.
What it means
ImportSession#publish_later (app/models/import_session.rb:248-259) wraps ImportSessionJob.perform_later in a rescue: if the ActiveJob adapter cannot enqueue (Redis/SolidQueue database down, adapter misconfiguration, serialization failure), it rolls the session back to its previous status, stores error_details {code: 'import_enqueue_failed'}, logs 'ImportSession enqueue failed import_session_id=... exception=...', and raises EnqueueError. The controller maps it to HTTP 503 {error: 'import_enqueue_failed', message: 'Import session could not be queued.'}.
Source
Thrown at app/models/import_session.rb:258
previous_status = status
update!(status: :importing, error_details: {})
should_enqueue = true
end
return unless should_enqueue
begin
ImportSessionJob.perform_later(self)
rescue => error
with_lock do
reload
if importing?
update!(status: previous_status, error_details: enqueue_error_details)
end
end
Rails.logger.error("ImportSession enqueue failed import_session_id=#{id} exception=#{error.class}")
raise EnqueueError, "Import session could not be queued."
end
end
def publish
return unless prepare_for_publish!
Rails.logger.info("ImportSession publish started import_session_id=#{id}")
imports.ordered_by_sequence.each do |import|
process_chunk!(import)
end
update!(status: :complete, summary: aggregate_chunk_summaries, error_details: {})
enqueue_family_sync
Rails.logger.info("ImportSession publish completed import_session_id=#{id}")
rescue => error
update!(
status: :failed,View on GitHub (pinned to e69894adb9)
Solutions
- Restore the queue backend (Redis reachable, SolidQueue migration ran, worker running), then call publish again — the status rollback makes the retry safe
- Grep logs for 'ImportSession enqueue failed import_session_id=… exception=…' to identify the underlying adapter error
- Verify config.active_job.queue_adapter and queue names match the running workers
- Confirm the session's error_details show import_enqueue_failed and its status returned to pending/failed before re-publishing
Example fix
# Ruby caller, before
session.publish_later # raises ImportSession::EnqueueError during a Redis outage
# after
begin
session.publish_later
rescue ImportSession::EnqueueError
retry_after_backend_restored { session.reload.publish_later } # session status was rolled back Defensive patterns
Strategy: retry
Validate before calling
# No request-side validation can guarantee a backend enqueue — check health first when possible
api.get('/up') # or your Redis/SolidQueue healthcheck, before triggering publish Try / catch
retries = 0 begin session.publish_later rescue ImportSession::EnqueueError retries += 1 raise if retries > 3 sleep(2**retries) # queue backend transient — session status was rolled back, retry is safe session.reload retry end
Prevention
- Monitor the queue backend (Redis/SolidQueue) and alert before it saturates
- Verify config.active_job.queue_adapter matches running workers in every environment
- After an outage, re-POST publish for sessions whose error_details show import_enqueue_failed — rollback makes it idempotent
When it happens
Trigger: POST /api/v1/import_sessions/:id/publish while the queue backend is unavailable or rejecting jobs: Redis connection refused, SolidQueue tables not migrated, Sidekiq/worker processes not running, or a queue-adapter mismatch.
Common situations: Redis outage or maintenance window; docker-compose restarted without the queue service; production using a different queue adapter than local; job arguments failing serialization after a model change.
Related errors
AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21).
Data as JSON: /api/errors/ea1e7c831117f48c.
Report an issue: GitHub.