{"record":{"id":"adb343a9549117c4","repo":"ducaale/xh","slug":"unknown-auth-type","errorCode":null,"errorMessage":"Unknown auth type {}","messagePattern":"Unknown auth type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/session.rs","lineNumber":248,"sourceCode":"        if let Auth {\n            auth_type: Some(auth_type),\n            raw_auth: Some(raw_auth),\n        } = &self.content.auth\n        {\n            match auth_type.as_str() {\n                \"basic\" => {\n                    let (username, password) = auth::parse_auth(raw_auth, \"\")?;\n                    Ok(Some(auth::Auth::Basic(username, password)))\n                }\n                \"digest\" => {\n                    let (username, password) = auth::parse_auth(raw_auth, \"\")?;\n                    Ok(Some(auth::Auth::Digest(\n                        username,\n                        password.unwrap_or_default(),\n                    )))\n                }\n                \"bearer\" => Ok(Some(auth::Auth::Bearer(raw_auth.into()))),\n                _ => Err(anyhow!(\"Unknown auth type {}\", raw_auth)),\n            }\n        } else {\n            Ok(None)\n        }\n    }\n\n    pub fn save_auth(&mut self, auth: &auth::Auth) {\n        match auth {\n            auth::Auth::Basic(username, password) => {\n                let password = password.as_deref().unwrap_or(\"\");\n                self.content.auth = Auth {\n                    auth_type: Some(\"basic\".into()),\n                    raw_auth: Some(format!(\"{username}:{password}\")),\n                }\n            }\n            auth::Auth::Digest(username, password) => {\n                self.content.auth = Auth {\n                    auth_type: Some(\"digest\".into()),","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/ducaale/xh/blob/2404aceecc08b0b2d100fedc96f57745cd5904dc/src/session.rs#L230-L266","documentation":"Match fallthrough in session's auth parsing: the session file's 'auth' object carries an authType that is not one of the recognized schemes ('basic', 'digest', ...), so no arm matches and the value is rejected as an unknown authentication type. This is a generic sentinel guard against corrupted or hand-edited session files containing an unsupported auth_type/raw_auth pair.","triggerScenarios":"Running `xh --auth-type=<anything-other-than-basic|digest|bearer> ...`, or loading a saved session file whose authType field contains an unrecognized value, or a typo like 'token', 'jwt', 'oauth'.","commonSituations":"Typo in --auth-type; copying flags from other HTTP clients (curl/HTTPie use different names); stale session JSON written by a newer/older xh version with different enum values.","solutions":["Use one of the supported values: basic, digest, or bearer","Fix the typo in --auth-type (e.g. 'Bearer' -> 'bearer'; it is lowercase)","Edit or delete the offending session file (~/.cache/xh/<host>_<port>) if its authType is invalid","If the scheme is not supported, pre-generate the header yourself and pass it via -A/--auth with basic or Authorization header"],"exampleFix":"// before\nxh --auth-type=oauth user:pass GET https://api.example.com\n// after\nxh --auth-type=bearer --auth=eyJhbGciOi... GET https://api.example.com","handlingStrategy":"validation","validationCode":"const VALID: [&str; 3] = [\"basic\", \"digest\", \"bearer\"];\nif let Some(t) = auth_type {\n    if !VALID.contains(&t.as_str()) {\n        eprintln!(\"auth-type must be one of basic|digest|bearer\");\n        std::process::exit(2);\n    }\n}","typeGuard":"fn is_valid_auth_type(s: &str) -> bool {\n    matches!(s, \"basic\" | \"digest\" | \"bearer\")\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().starts_with(\"Unknown auth type\") => {\n        eprintln!(\"use --auth-type=basic|digest|bearer\");\n    }\n    r => r?,\n}","preventionTips":["Always lowercase --auth-type values","Check `xh --help` for supported auth types before scripting","Validate session files' authType when editing them by hand"],"tags":["cli","auth","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"2404aceecc08b0b2d100fedc96f57745cd5904dc","analyzedAt":"2026-09-13T19:13:33.814Z","contentChangedAt":"2026-09-13T19:13:33.814Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}