{"record":{"id":"34044c2ed7636664","repo":"reacherhq/check-if-email-exists","slug":"invalid-port","errorCode":null,"errorMessage":"Invalid port: {}","messagePattern":"Invalid port: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/src/http/mod.rs","lineNumber":77,"sourceCode":"/// This function starts the Warp server and listens for incoming requests.\n/// It returns a `Result` indicating whether the server started successfully or\n/// encountered an error, as well as an optional `JobRunnerHandle` if the bulk\n/// job listener is enabled. The handle can be used to stop the listener or to\n/// keep it alive.\npub async fn run_warp_server(\n\tconfig: Arc<BackendConfig>,\n) -> Result<Option<JobRunnerHandle>, anyhow::Error> {\n\tlet host = config\n\t\t.http_host\n\t\t.parse::<IpAddr>()\n\t\t.unwrap_or_else(|_| panic!(\"Invalid host: {}\", config.http_host));\n\t// For backwards compatibility, we allow the port to be set via the\n\t// environment variable PORT, instead of the new configuration file. The\n\t// PORT environment variable takes precedence.\n\tlet port = env::var(\"PORT\")\n\t\t.map(|port: String| {\n\t\t\tport.parse::<u16>()\n\t\t\t\t.unwrap_or_else(|_| panic!(\"Invalid port: {}\", port))\n\t\t})\n\t\t.unwrap_or(config.http_port);\n\n\tlet routes = create_routes(Arc::clone(&config));\n\n\t// Run v0 bulk job listener.\n\tlet is_bulk_enabled = env::var(\"RCH_ENABLE_BULK\").unwrap_or_else(|_| \"0\".into()) == \"1\";\n\tlet runner = if is_bulk_enabled {\n\t\tlet pg_pool = config.get_pg_pool().expect(\n\t\t\t\"Please set the RCH__STORAGE__POSTGRES__DB_URL environment when RCH_ENABLE_BULK is set\",\n\t\t);\n\t\tlet runner = v0::bulk::create_job_registry(&pg_pool).await?;\n\t\tSome(runner)\n\t} else {\n\t\tNone\n\t};\n\n\tinfo!(target: LOG_TARGET, host=?host,port=?port, \"Server is listening\");","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/reacherhq/check-if-email-exists/blob/81da93e8a419f601c05e1bcf4a197d25eb0e349d/backend/src/http/mod.rs#L59-L95","documentation":"When the PORT environment variable is set, run_warp_server parses it as u16; if it fails to parse, it panics with 'Invalid port: {}'. This fail-fast guard catches misconfigured port values before binding the HTTP server.","triggerScenarios":"PORT env var set to a non-numeric string, a value above 65535, an empty string, or containing whitespace when run_warp_server starts.","commonSituations":"PLATFORM sets PORT to a named value or blank; quoting issues in docker-compose leaving quotes in the value; trailing newline in an .env file.","solutions":["Set PORT to a valid numeric port between 1 and 65535","Unset PORT so the server falls back to config.http_port","Trim whitespace/quotes from the value in your .env or orchestrator config"],"exampleFix":"// before\nPORT=\"8o80\" docker run reacher-backend\n// after\nPORT=8080 docker run reacher-backend","handlingStrategy":"validation","validationCode":"if let Ok(port) = std::env::var(\"PORT\") {\n    let ok = port.trim().parse::<u16>().is_ok();\n    if !ok { eprintln!(\"PORT '{}' is not a valid u16\", port); std::process::exit(1); }\n}","typeGuard":"fn is_valid_port(s: &str) -> bool { s.trim().parse::<u16>().is_ok() }","tryCatchPattern":null,"preventionTips":["Ensure PORT is unset or a plain integer 1-65535","Watch for quotes/newlines leaking from .env files and orchestrators","Prefer setting the port in the config file over the PORT env var"],"tags":["config","env-var","panic","port"],"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"}