{"record":{"id":"da6ca84d6c60ffe9","repo":"microsoft/garnet","slug":"unable-to-parse-input-password-hash-the-input-is-da6ca8","errorCode":null,"errorMessage":"Unable to parse input password hash. The input is not of the correct format.","messagePattern":"Unable to parse input password hash\\. The input is not of the correct format\\.","errorType":"validation","errorClass":"ACLPasswordException","httpStatus":null,"severity":"error","filePath":"libs/server/ACL/ACLPassword.cs","lineNumber":66,"sourceCode":"        {\n            if (hashString.Length != 2 * NumHashBytes)\n            {\n                throw new ACLPasswordException(\"Unable to parse input password hash. The input is of wrong length.\");\n            }\n\n            // Parse input byte by byte\n            byte[] hash = new byte[NumHashBytes];\n            try\n            {\n                for (int i = 0; i < hash.Length; i++)\n                {\n                    string byteString = hashString.Substring(i * 2, 2);\n                    hash[i] = byte.Parse(byteString, NumberStyles.HexNumber, CultureInfo.InvariantCulture);\n                }\n            }\n            catch (FormatException)\n            {\n                throw new ACLPasswordException(\"Unable to parse input password hash. The input is not of the correct format.\");\n            }\n\n            return new ACLPassword(hash);\n        }\n\n        /// <summary>\n        /// Outputs the hexadecimal representation of the password hash.\n        /// </summary>\n        /// <returns>Password hash as hex-string.</returns>\n        public override string ToString()\n        {\n            var stringBuilder = new StringBuilder();\n\n            for (int i = 0; i < PasswordHash.Length; i++)\n            {\n                stringBuilder.Append(PasswordHash[i].ToString(\"x2\"));\n            }\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/ACL/ACLPassword.cs#L48-L84","documentation":"Thrown by ACLPassword.ACLPasswordFromHash when the input is the correct length (64 chars) but contains non-hexadecimal characters. The byte-by-byte byte.Parse with NumberStyles.HexNumber throws FormatException, which is caught and rethrown as ACLPasswordException. So length is fine but content is not valid hex.","triggerScenarios":"A 64-character string that includes letters beyond a-f/A-F (e.g. 'g','z'), punctuation, or spaces; a base64-encoded hash that happens to be 64 chars; a hash with mixed-in dashes or colons (e.g. 'ab:cd:...').","commonSituations":"Copying a hash that was displayed with separators (colons in some tools); a hash with an embedded whitespace character; a UUID-like or otherwise non-hex representation of the right length.","solutions":["Strip any non-hex characters (colons, dashes, spaces) before parsing.","Confirm the string is pure hexadecimal [0-9a-fA-F].","Regenerate the hash from the cleartext using ACLPassword.ACLPasswordFromString if unsure.","Pre-validate with a regex ^[0-9a-fA-F]{64}$ before calling."],"exampleFix":"// before\nvar p = ACLPassword.ACLPasswordFromHash(\"ab:cd:...:ef\"); // 64 chars with colons\n\n// after\nvar clean = new string(hash.Where(char.IsLetterOrDigit).ToArray());\nvar p = ACLPassword.ACLPasswordFromHash(clean);","handlingStrategy":"validation","validationCode":"if (!System.Text.RegularExpressions.Regex.IsMatch(hashString, @\"^[0-9a-fA-F]{64}$\"))\n    throw new ArgumentException(\"Password hash must be 64 hexadecimal characters.\");","typeGuard":"static bool IsHexHash(string s) =>\n    s != null && s.Length == 64 && System.Text.RegularExpressions.Regex.IsMatch(s, @\"^[0-9a-fA-F]{64}$\");","tryCatchPattern":"try { var p = ACLPassword.ACLPasswordFromHash(hash); }\ncatch (ACLPasswordException ex) when (ex.Message.Contains(\"format\")) { /* strip separators, retry */ }","preventionTips":["Strip colons/dashes/spaces from hashes before parsing.","Validate with ^[0-9a-fA-F]{64}$ before calling.","Regenerate from cleartext if format is uncertain."],"tags":["acl","password","hash","hex","validation"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}