{"record":{"id":"d6fda01a2c2f9ae4","repo":"leptos-rs/leptos","slug":"error","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"panic","errorClass":"LeptosConfigError","httpStatus":null,"severity":"error","filePath":"leptos_config/src/lib.rs","lineNumber":332,"sourceCode":"        ENV_PROD_KEY_SHORT | ENV_PROD_KEY_LONG => Ok(Env::PROD),\n        _ => Err(LeptosConfigError::EnvVarError(format!(\n            \"{input} is not a supported environment. Use either \\\n             `{ENV_DEV_KEY_SHORT}`, `{ENV_DEV_KEY_LONG}`, \\\n             `{ENV_PROD_KEY_SHORT}`, or `{ENV_PROD_KEY_LONG}`.\",\n        ))),\n    }\n}\n\nimpl FromStr for Env {\n    type Err = ();\n    fn from_str(input: &str) -> Result<Self, Self::Err> {\n        env_from_str(input).or_else(|_| Ok(Self::default()))\n    }\n}\n\nimpl From<&str> for Env {\n    fn from(str: &str) -> Self {\n        env_from_str(str).unwrap_or_else(|err| panic!(\"{}\", err))\n    }\n}\n\nimpl From<&Result<String, VarError>> for Env {\n    fn from(input: &Result<String, VarError>) -> Self {\n        match input {\n            Ok(str) => {\n                env_from_str(str).unwrap_or_else(|err| panic!(\"{}\", err))\n            }\n            Err(_) => Self::default(),\n        }\n    }\n}\n\nimpl TryFrom<String> for Env {\n    type Error = LeptosConfigError;\n\n    fn try_from(s: String) -> Result<Self, Self::Error> {","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/leptos_config/src/lib.rs#L314-L350","documentation":"`impl From<&str> for Env` parses a string into the Env enum via env_from_str and panics with the parse error when the string is not a recognized environment name. This is used when converting user-provided config strings, so an invalid value aborts instead of falling back.","triggerScenarios":"Calling `.into()` / `Env::from(some_str)` with a string that is not a recognized environment (dev/development, prod/production, test variants accepted by env_from_str).","commonSituations":"Setting LEPTOS_ENV to a typo like \"prodaction\" in .env or the environment; loading config where env is read from a string and converted with From<&str>.","solutions":["Set LEPTOS_ENV (or the string being converted) to a valid value: dev/development, prod/production, or test.","If a default should be used instead of panicking, call env_from_str and handle the Err yourself.","Use the &Result<String, VarError> conversion (Err falls back to default) instead of From<&str> for raw env-var reads."],"exampleFix":"// before\nlet env: Env = \"production\".to_string().as_str().into(); // panics on typo'd input\n// after\nlet env = env_from_str(\"production\").unwrap_or(Env::default());","handlingStrategy":"validation","validationCode":"fn parse_env_safe(s: &str) -> Option<Env> { env_from_str(s).ok() }","typeGuard":"fn is_valid_env(s: &str) -> bool {\n    matches!(s.to_lowercase().as_str(), \"dev\" | \"development\" | \"prod\" | \"production\" | \"test\")\n}","tryCatchPattern":"// Env::from panics, so validate first:\nlet raw = std::env::var(\"LEPTOS_ENV\").unwrap_or_default();\nlet env = if is_valid_env(&raw) { raw.as_str().into() } else { Env::default() };","preventionTips":["Use only dev/development, prod/production, test for LEPTOS_ENV.","Pin config in committed .env files and lint them in CI.","Prefer explicit env_from_str parsing over the panicking From<&str>."],"tags":["rust","config","env","panic","parsing"],"backgroundTag":"invalid-config-env-value","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}