{"record":{"id":"ac1e0fac3f263f6e","repo":"nautechsystems/nautilus_trader","slug":"redis-config-error-username-supplied-without-pass","errorCode":null,"errorMessage":"Redis config error: username supplied without password. Either supply a password or omit the username.","messagePattern":"Redis config error: username supplied without password\\. Either supply a password or omit the username\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/infrastructure/src/redis/mod.rs","lineNumber":132,"sourceCode":"        } else {\n            pw.to_owned()\n        }\n    };\n\n    // Build the `userinfo@` portion for both the real and redacted URLs.\n    let (auth, auth_redacted) = match (username.is_empty(), password.is_empty()) {\n        // user:pass@\n        (false, false) => (\n            format!(\"{username}:{password}@\"),\n            format!(\"{username}:{}@\", redact_pw(password)),\n        ),\n        // :pass@\n        (true, false) => (\n            format!(\":{password}@\"),\n            format!(\":{}@\", redact_pw(password)),\n        ),\n        // username but no password ⇒  configuration error\n        (false, true) => panic!(\n            \"Redis config error: username supplied without password. \\\n            Either supply a password or omit the username.\"\n        ),\n        // no credentials\n        (true, true) => (String::new(), String::new()),\n    };\n\n    let scheme = if ssl { \"rediss\" } else { \"redis\" };\n\n    let url = format!(\"{scheme}://{auth}{host}:{port}\");\n    let redacted_url = format!(\"{scheme}://{auth_redacted}{host}:{port}\");\n\n    (url, redacted_url)\n}\n\n/// Creates a new Redis connection manager based on the provided database `config` and connection name.\n///\n/// # Errors","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/mod.rs#L114-L150","documentation":"`get_redis_url` in crates/infrastructure/src/redis/mod.rs validates the credential configuration and panics when a username is provided without a password. A Redis URL with credentials requires both parts (or neither); the partial combination would produce a malformed/ambiguous URL, so the function treats it as a hard configuration error. This is a user-facing config mistake surfaced as a panic at connection-setup time.","triggerScenarios":"Building a RedisConfig with `username` set but `password` None/empty, then calling `get_redis_url` (directly or via `create_redis_connection`). The match arm `(false, true)` (no password, username present) triggers the panic.","commonSituations":"Redis Cloud/MemoryDB setups where only a username is copied from the console; partially redacted configs where the password env var is unset but the username is set; mistyping the password env variable name.","solutions":["Supply the password alongside the username in the Redis config (check the relevant env var, e.g. REDIS_PASSWORD, is actually set).","Remove the username if the Redis instance does not use authentication (omit both).","Validate the config before startup: assert password.is_some() whenever username is set."],"exampleFix":"// before\nRedisConfig { username: Some(\"default\".into()), password: None, .. } // panics\n\n// after\nRedisConfig { username: Some(\"default\".into()), password: Some(\"secret\".into()), .. }\n// or username: None, password: None","handlingStrategy":"validation","validationCode":"// before building the config\nif config.username.is_some() && config.password.as_deref().map_or(true, str::is_empty) {\n    return Err(\"password required when username is set\");\n}","typeGuard":null,"tryCatchPattern":"// validate config at startup and fail fast with a clear message:\nvalidate_redis_config(&cfg).expect(\"invalid Redis credentials: username requires password\");","preventionTips":["Set both REDIS username and password env vars together, or neither.","Check env var spelling and container secret mounting when credentials look partial.","Run a config preflight check before the node connects to Redis."],"tags":["rust","redis","panic","configuration","credentials"],"backgroundTag":"missing-credentials","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}