{"record":{"id":"3b8fd0bf74175d4e","repo":"we-promise/sure","slug":"redis-sentinel-hosts-is-set-but-no-valid-sentinel","errorCode":null,"errorMessage":"REDIS_SENTINEL_HOSTS is set but no valid sentinel hosts found, falling back to REDIS_URL","messagePattern":"REDIS_SENTINEL_HOSTS is set but no valid sentinel hosts found, falling back to REDIS_URL","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"config/initializers/sidekiq.rb","lineNumber":41,"sourceCode":"    parts = host_port.strip.split(\":\", 2)\n    host = parts[0]&.strip\n    port_str = parts[1]&.strip\n\n    next if host.blank?\n\n    # Parse port with validation, default to 26379 if invalid or missing\n    port = if port_str.present?\n      port_int = port_str.to_i\n      (port_int > 0 && port_int <= 65535) ? port_int : 26379\n    else\n      26379\n    end\n\n    { host: host, port: port }\n  end\n\n  if sentinels.empty?\n    Rails.logger.warn(\"REDIS_SENTINEL_HOSTS is set but no valid sentinel hosts found, falling back to REDIS_URL\")\n    { url: ENV.fetch(\"REDIS_URL\", \"redis://localhost:6379/0\") }\n  else\n    {\n      url: \"redis://#{ENV.fetch('REDIS_SENTINEL_MASTER', 'mymaster')}/0\",\n      sentinels: sentinels,\n      password: ENV[\"REDIS_PASSWORD\"],\n      sentinel_username: ENV.fetch(\"REDIS_SENTINEL_USERNAME\", \"default\"),\n      sentinel_password: ENV[\"REDIS_PASSWORD\"],\n      role: :master,\n      # Recommended timeouts for Sentinel\n      connect_timeout: 0.2,\n      read_timeout: 1,\n      write_timeout: 1,\n      reconnect_attempts: 3\n    }\n  end\nelse\n  # Standard Redis URL configuration (no Sentinel)","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/config/initializers/sidekiq.rb#L23-L59","documentation":"The Sidekiq initializer parses REDIS_SENTINEL_HOSTS as a comma-separated host[:port] list; each entry is split on \":\", stripped, and dropped when the host part is blank (filter_map with next if host.blank?). Ports out of range are coerced to 26379, but blank hosts remove the entry. If every entry is dropped, the sentinel list is empty, the initializer warns, and Sidekiq silently falls back to a plain REDIS_URL connection (default redis://localhost:6379/0), bypassing Sentinel HA entirely.","triggerScenarios":"REDIS_SENTINEL_HOSTS is set to a value that contains no usable host: \",\", \" , , \", \";\", a value made only of port fragments like \":26379\", or a quoted comma artifact like '\",\"' from templating. Any single non-blank host (even misspelled) would produce a sentinel entry instead, so this warning specifically means all entries had blank host parts (config/initializers/sidekiq.rb:22-42).","commonSituations":"docker-compose/Kubernetes templating that interpolates an empty variable leaving placeholder commas; secret managers injecting an empty or comma-only string; switching a deployment from Sentinel to plain Redis and leaving a stray value; environment files where the variable name is duplicated and one instance is empty.","solutions":["Set REDIS_SENTINEL_HOSTS to a proper comma-separated list of host:port pairs, e.g. sentinel1:26379,sentinel2:26379,sentinel3:26379","Print the variable in the app's environment (rails runner 'puts ENV[\"REDIS_SENTINEL_HOSTS\"].inspect') to expose stray quotes, semicolons, or comma-only content","If Sentinel is not intended, unset REDIS_SENTINEL_HOSTS entirely and configure REDIS_URL instead so the fallback is the real configuration","When Sentinel is intended, also set REDIS_SENTINEL_MASTER (default mymaster) and REDIS_PASSWORD so the sentinel config block is complete"],"exampleFix":"# .env - before\nREDIS_SENTINEL_HOSTS=,,\n\n# .env - after\nREDIS_SENTINEL_HOSTS=sentinel1:26379,sentinel2:26379,sentinel3:26379\nREDIS_SENTINEL_MASTER=mymaster\nREDIS_PASSWORD=secret","handlingStrategy":"validation","validationCode":"# Validate sentinel host parsing before Sidekiq boots (initializer or rake task)\nif (raw = ENV[\"REDIS_SENTINEL_HOSTS\"]).present?\n  hosts = raw.split(\",\").filter_map { |e| e.strip.split(\":\", 2)[0]&.strip }.reject(&:blank?)\n  if hosts.empty?\n    raise \"REDIS_SENTINEL_HOSTS='#{raw}' contains no valid hosts - fix or unset it (it currently falls back to REDIS_URL)\"\n  end\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Template environment files with concrete host:port examples (sentinel1:26379,...) instead of placeholder commas","Alert on the exact warning string in deployment logs — it always means Sentinel HA was silently disabled","Include Redis connectivity (URL and sentinel modes) in a deploy preflight check"],"tags":["redis","sidekiq","sentinel","environment-variables","configuration"],"backgroundTag":"redis-connection-config","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}