{"record":{"id":"fc3be9584d156588","repo":"reacherhq/check-if-email-exists","slug":"environment-variable-rch-maximum-concurrent-task-f","errorCode":null,"errorMessage":"Environment variable RCH_MAXIMUM_CONCURRENT_TASK_FETCH should parse to usize","messagePattern":"Environment variable RCH_MAXIMUM_CONCURRENT_TASK_FETCH should parse to usize","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/src/http/v0/bulk/mod.rs","lineNumber":41,"sourceCode":"\nuse std::env;\n\nuse check_if_email_exists::LOG_TARGET;\nuse sqlx::{Pool, Postgres};\nuse sqlxmq::{JobRegistry, JobRunnerHandle};\nuse tracing::info;\n\npub use task::email_verification_task;\n\n/// Create a job registry with one task: the email verification task.\npub async fn create_job_registry(pool: &Pool<Postgres>) -> Result<JobRunnerHandle, sqlx::Error> {\n\tlet min_task_conc = env::var(\"RCH_MINIMUM_TASK_CONCURRENCY\").map_or(10, |var| {\n\t\tvar.parse::<usize>()\n\t\t\t.expect(\"Environment variable RCH_MINIMUM_TASK_CONCURRENCY should parse to usize\")\n\t});\n\tlet max_conc_task_fetch = env::var(\"RCH_MAXIMUM_CONCURRENT_TASK_FETCH\").map_or(20, |var| {\n\t\tvar.parse::<usize>()\n\t\t\t.expect(\"Environment variable RCH_MAXIMUM_CONCURRENT_TASK_FETCH should parse to usize\")\n\t});\n\n\t// registry needs to be given list of jobs it can accept\n\tlet registry = JobRegistry::new(&[email_verification_task]);\n\n\t// create runner for the message queue associated\n\t// with this job registry\n\tlet registry = registry\n\t\t// Create a job runner using the connection pool.\n\t\t.runner(pool)\n\t\t// Here is where you can configure the job runner\n\t\t// Aim to keep 10-20 jobs running at a time.\n\t\t.set_concurrency(min_task_conc, max_conc_task_fetch)\n\t\t// Start the job runner in the background.\n\t\t.run()\n\t\t.await?;\n\n\tinfo!(","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/reacherhq/check-if-email-exists/blob/81da93e8a419f601c05e1bcf4a197d25eb0e349d/backend/src/http/v0/bulk/mod.rs#L23-L59","documentation":"Identical mechanism to error 7 but for RCH_MAXIMUM_CONCURRENT_TASK_FETCH: create_job_registry parses this env var as usize with expect(), so any set-but-unparseable value panics the process during job registry creation.","triggerScenarios":"RCH_MAXIMUM_CONCURRENT_TASK_FETCH is set to a non-numeric string, a negative number, or a value larger than usize::MAX when create_job_registry runs at startup.","commonSituations":"Misconfigured systemd/docker env files with unit suffixes or stray characters; copy-pasted values like \"1,000\"; conflicts with languages expecting \"0\" allowed while code assumes positive values (0 parses fine, so this is mostly about non-numeric input).","solutions":["Set RCH_MAXIMUM_CONCURRENT_TASK_FETCH to a plain non-negative integer (e.g. 20).","Unset the variable to use the built-in default of 20.","Check for stray whitespace, commas, or quotes in the value's source (env file, CI secret).","Replace the expect() with graceful error handling."],"exampleFix":"// before\nRCH_MAXIMUM_CONCURRENT_TASK_FETCH=1,000\n// after\nRCH_MAXIMUM_CONCURRENT_TASK_FETCH=1000","handlingStrategy":"validation","validationCode":"let max_conc_task_fetch = std::env::var(\"RCH_MAXIMUM_CONCURRENT_TASK_FETCH\")\n    .map_or(Ok(20usize), |v| v.trim().parse::<usize>().map_err(|e| anyhow!(\"RCH_MAXIMUM_CONCURRENT_TASK_FETCH={v:?} is not a valid usize: {e}\")))?;","typeGuard":"fn parse_usize_env(name: &str) -> Result<Option<usize>, anyhow::Error> {\n    match std::env::var(name) {\n        Err(_) => Ok(None),\n        Ok(v) => v.trim().parse::<usize>().map(Some).map_err(|e| anyhow!(\"{name}={v:?} is not a valid usize: {e}\")),\n    }\n}","tryCatchPattern":"match std::env::var(\"RCH_MAXIMUM_CONCURRENT_TASK_FETCH\") {\n    Ok(v) => match v.trim().parse::<usize>() {\n        Ok(n) => n,\n        Err(e) => { eprintln!(\"invalid RCH_MAXIMUM_CONCURRENT_TASK_FETCH={v}: {e}\"); std::process::exit(1); }\n    },\n    Err(_) => 20,\n}","preventionTips":["Store the value as a plain integer (e.g. 1000, not 1,000 or 1000ms).","Leave the variable unset to use the default of 20 when unsure.","Diff env files between environments before deploying."],"tags":["env-var","parsing","panic","configuration"],"backgroundTag":"invalid-env-var-value","analyzedSha":"81da93e8a419f601c05e1bcf4a197d25eb0e349d","analyzedAt":"2026-09-11T10:06:14.663Z","contentChangedAt":"2026-09-11T10:06:14.663Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}