{"record":{"id":"ea1e7c831117f48c","repo":"we-promise/sure","slug":"import-enqueue-failed","errorCode":"import_enqueue_failed","errorMessage":"Import session could not be queued.","messagePattern":"Import session could not be queued\\.","errorType":"http","errorClass":"ImportSession::EnqueueError","httpStatus":503,"severity":"critical","filePath":"app/models/import_session.rb","lineNumber":258,"sourceCode":"\n      previous_status = status\n      update!(status: :importing, error_details: {})\n      should_enqueue = true\n    end\n\n    return unless should_enqueue\n\n    begin\n      ImportSessionJob.perform_later(self)\n    rescue => error\n      with_lock do\n        reload\n        if importing?\n          update!(status: previous_status, error_details: enqueue_error_details)\n        end\n      end\n      Rails.logger.error(\"ImportSession enqueue failed import_session_id=#{id} exception=#{error.class}\")\n      raise EnqueueError, \"Import session could not be queued.\"\n    end\n  end\n\n  def publish\n    return unless prepare_for_publish!\n\n    Rails.logger.info(\"ImportSession publish started import_session_id=#{id}\")\n\n    imports.ordered_by_sequence.each do |import|\n      process_chunk!(import)\n    end\n\n    update!(status: :complete, summary: aggregate_chunk_summaries, error_details: {})\n    enqueue_family_sync\n    Rails.logger.info(\"ImportSession publish completed import_session_id=#{id}\")\n  rescue => error\n    update!(\n      status: :failed,","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/import_session.rb#L240-L276","documentation":"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.'}.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# Ruby caller, before\nsession.publish_later # raises ImportSession::EnqueueError during a Redis outage\n\n# after\nbegin\n  session.publish_later\nrescue ImportSession::EnqueueError\n  retry_after_backend_restored { session.reload.publish_later } # session status was rolled back","handlingStrategy":"retry","validationCode":"# No request-side validation can guarantee a backend enqueue — check health first when possible\napi.get('/up') # or your Redis/SolidQueue healthcheck, before triggering publish","typeGuard":null,"tryCatchPattern":"retries = 0\nbegin\n  session.publish_later\nrescue ImportSession::EnqueueError\n  retries += 1\n  raise if retries > 3\n  sleep(2**retries) # queue backend transient — session status was rolled back, retry is safe\n  session.reload\n  retry\nend","preventionTips":["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"],"tags":["rails","import-session","activejob","queue-backend","infrastructure","http-503"],"backgroundTag":"job-enqueue-failed","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}