{"record":{"id":"505eee3ab34fdebd","repo":"reacherhq/check-if-email-exists","slug":"environment-variable-rch-minimum-task-concurrency","errorCode":null,"errorMessage":"Environment variable RCH_MINIMUM_TASK_CONCURRENCY should parse to usize","messagePattern":"Environment variable RCH_MINIMUM_TASK_CONCURRENCY should parse to usize","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/src/http/v0/bulk/mod.rs","lineNumber":37,"sourceCode":"pub mod get;\npub mod post;\npub mod results;\nmod task;\n\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.","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/reacherhq/check-if-email-exists/blob/81da93e8a419f601c05e1bcf4a197d25eb0e349d/backend/src/http/v0/bulk/mod.rs#L19-L55","documentation":"create_job_registry reads RCH_MINIMUM_TASK_CONCURRENCY from the environment and parses it as usize; if the variable is set but not a valid unsigned integer, parse() fails and expect() panics with this message. It is a startup-time configuration validation panic, not a recoverable runtime error.","triggerScenarios":"RCH_MINIMUM_TASK_CONCURRENCY is exported with a non-numeric, negative (e.g. \"-1\"), or overflowing value when create_job_registry initializes the bulk-email-verification job registry.","commonSituations":"Ops staff setting the variable with a unit suffix (\"10m\"), quotes/whitespace, or a negative number; value set in a CI/CD secrets store as a placeholder string like \"SET_ME\".","solutions":["Set RCH_MINIMUM_TASK_CONCURRENCY to a plain non-negative integer (e.g. 10).","Unset the variable to use the built-in default of 10.","Trim whitespace/quotes from the value in the environment or process manager config.","Replace the expect() with proper error handling if a graceful startup failure is preferred."],"exampleFix":"// before\nvar.parse::<usize>().expect(\"Environment variable RCH_MINIMUM_TASK_CONCURRENCY should parse to usize\")\n// after\nvar.parse::<usize>().unwrap_or_else(|_| panic!(\"RCH_MINIMUM_TASK_CONCURRENCY='{}' is not a valid usize\", var))","handlingStrategy":"validation","validationCode":"let min_task_conc = std::env::var(\"RCH_MINIMUM_TASK_CONCURRENCY\")\n    .map_or(Ok(10usize), |v| v.trim().parse::<usize>().map_err(|e| anyhow!(\"RCH_MINIMUM_TASK_CONCURRENCY={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_MINIMUM_TASK_CONCURRENCY\") {\n    Ok(v) => match v.trim().parse::<usize>() {\n        Ok(n) => n,\n        Err(e) => { eprintln!(\"invalid RCH_MINIMUM_TASK_CONCURRENCY={v}: {e}\"); std::process::exit(1); }\n    },\n    Err(_) => 10,\n}","preventionTips":["Set env values as bare non-negative integers with no units, quotes, or thousand separators.","Prefer leaving the variable unset rather than guessing a value; defaults exist (10).","Add a startup smoke test in CI that parses all RCH_* variables."],"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-16T04:17:20.429Z"}