{"record":{"id":"0efe603ad44b2a11","repo":"Pumpkin-MC/Pumpkin","slug":"the-validated-username-is-invalid","errorCode":null,"errorMessage":"The validated username is invalid","messagePattern":"The validated username is invalid","errorType":"error_code","errorClass":"LoginError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin/src/net/bedrock/login/mod.rs","lineNumber":36,"sourceCode":"    client::{resource_pack_stack::PackInstanceId, resource_packs_info::PackInfoData},\n    server::{login::ClientData, resource_pack_client_response::SResourcePackClientResponse},\n};\nuse pumpkin_util::version::BedrockMinecraftVersion;\nuse pumpkin_world::{CURRENT_BEDROCK_MC_PROTOCOL, CURRENT_BEDROCK_MC_VERSION};\nuse serde::{Deserialize, de::Error};\nuse serde_repr::Deserialize_repr;\nuse std::sync::Arc;\nuse thiserror::Error;\nuse tracing::debug;\nuse uuid::Uuid;\n\n#[derive(Debug, Error)]\npub enum LoginError {\n    #[error(\"Login packet data is not valid JSON\")]\n    InvalidTokenFormat(#[from] serde_json::Error),\n    #[error(\"JWT chain validation failed: {0}\")]\n    ChainValidationFailed(#[from] AuthError),\n    #[error(\"The validated username is invalid\")]\n    InvalidUsername,\n    #[error(\"Could not parse UUID from validated token\")]\n    InvalidUuid,\n    #[error(\"Cannot accept self-signed token. Authentication is enforced by server config.\")]\n    SelfSignedNotAllowed,\n    #[error(\"Got a guest/splitscreen login request. Currently unimplemented.\")]\n    GuestUnimplemented,\n    #[error(\"Failed to decode extra using decode_b64_url_nopad.\")]\n    DecodeExtraError,\n}\n\n#[derive(Deserialize_repr)]\n#[repr(u8)]\nenum AuthenticationType {\n    Full,\n    Guest,\n    SelfSigned,\n}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/net/bedrock/login/mod.rs#L18-L54","documentation":"This is the LoginError::InvalidUsername variant. After successfully validating the JWT chain, Pumpkin extracts the gamertag/username from the authenticated token and rejects it if it does not pass the server's username validity checks. It is thrown so that clients with malformed, empty, or disallowed names never enter the world state.","triggerScenarios":"The username decoded from the validated Bedrock login token is empty, exceeds length limits, contains characters outside the allowed set, or otherwise fails the game's name rules (e.g. same rules as Java edition names).","commonSituations":"Modified clients that send a blank or spoofed gamertag, accounts with unusual characters in their Xbox gamertag, or third-party tools crafting login packets for testing.","solutions":["Have the player ensure their Xbox Live gamertag is a normal, non-empty name and re-login","If testing with a custom client, send a username that satisfies the vanilla name rules (length and allowed characters)","Check the server's username validation config/pattern if it has been customized too strictly","Update the server if the username rules changed in a newer version"],"exampleFix":"// before (custom client payload)\nlet token = build_login_jwt(\"\"); // empty username\n// after\nlet token = build_login_jwt(\"ValidName123\"); // conforms to name rules","handlingStrategy":"validation","validationCode":"// Caller-side name check before sending a login packet\nfn is_valid_username(name: &str) -> bool {\n    !name.is_empty()\n        && name.len() <= 16\n        && name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_')\n}","typeGuard":"fn is_invalid_username(e: &LoginError) -> bool {\n    matches!(e, LoginError::InvalidUsername)\n}","tryCatchPattern":"match login_result {\n    Err(LoginError::InvalidUsername) => disconnect_with(\"Your gamertag is not allowed; please change it on Xbox Live\"),\n    Err(e) => disconnect_with(&format!(\"Login failed: {e}\")),\n    Ok(p) => admit(p),\n}","preventionTips":["Use a standard gamertag (letters, digits, underscore, reasonable length)","Validate names in custom clients before building the login packet","Keep server-side name rules aligned with vanilla conventions","Reject blank names early in any test tooling"],"tags":["authentication","validation","bedrock","minecraft","username"],"backgroundTag":"invalid-identifier-format","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}