reacherhq/check-if-email-exists · error · anyhow::Error
When worker mode is enabled, a Postgres database must be…
Error message
When worker mode is enabled, a Postgres database must be configured.
What it means
load_config validates that when the worker feature is enabled (cfg.worker.enable), the storage field is configured as Postgres. Any other storage (or none) makes it bail with 'When worker mode is enabled, a Postgres database must be configured.' The worker persists job state in Postgres, so this is a hard requirement.
Solutions
- Add a [storage.postgres] section with the database URL to the config
- If no database is intended, disable worker mode (worker.enable = false)
- Verify the storage key spelling so it parses as StorageConfig::Postgres
Example fix
// before [worker] enable = true // no storage configured -> bail // after [worker] enable = true [storage.postgres] url = "postgres://user:pass@localhost/reacher"
Defensive patterns
Strategy: validation
Validate before calling
if config.worker.enable
&& !matches!(&config.storage, Some(StorageConfig::Postgres(_)))
{
eprintln!("Worker mode requires [storage.postgres] to be configured");
std::process::exit(1);
} Try / catch
if let Err(e) = load_config() {
if e.to_string().contains("Postgres database must be configured") {
eprintln!("Add [storage.postgres] or disable worker mode");
}
return Err(e);
} Prevention
- Whenever enabling worker mode, also configure storage.postgres
- Keep a validated example config for worker deployments
- Check for key-name typos (storage) that silently become None
When it happens
Trigger: Running the backend with worker.enable = true while storage is None or set to a non-Postgres StorageConfig variant.
Common situations: Worker beta flag turned on in a deployment that previously used no database; copying an API-server config and enabling worker without adding the Postgres storage section; storage key typo so it deserializes as None.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Worker configuration is missing
- Calling must_worker_config on a non-worker backend
- Invalid host
- Invalid port
- Worker configuration is missing the rabbitmq configuration
AI-assisted analysis of reacherhq/check-if-email-exists@81da93e8a4 (2026-09-11).
Data as JSON: /api/errors/609b7503a401e421.
Report an issue: GitHub.
Appendix: source
Thrown at backend/src/config.rs:334
/// Load the worker configuration from the worker_config.toml file and from the
/// environment.
pub async fn load_config() -> Result<BackendConfig, anyhow::Error> {
let cfg = Config::builder()
.add_source(config::File::with_name("backend_config"))
.add_source(config::Environment::with_prefix("RCH").separator("__"));
let cfg = cfg.build()?.try_deserialize::<BackendConfig>()?;
// Perform additional checks
// 1. Make sure that if the worker is enabled, a Postgres database is configured.
if cfg.worker.enable {
warn!(target: LOG_TARGET, "The worker feature is currently in beta. Please send any feedback to amaury@reacher.email.");
match &cfg.storage {
Some(StorageConfig::Postgres(_)) => {}
_ => bail!("When worker mode is enabled, a Postgres database must be configured."),
}
}
// 2. Validate the verif_method proxies, meaning that for each email
// provider's verification method, the proxy (if set) must exist in the
// `proxies` field.
cfg.get_verif_method().validate_proxies()?;
Ok(cfg)
}
#[cfg(test)]
mod tests {
use super::*;
use serial_test::serial;
use std::{env, time::Duration};
use {
EverythingElseVerifMethod, GmailVerifMethod, HotmailB2BVerifMethod, VerifMethodSmtpConfig,View on GitHub (pinned to 81da93e8a4)