microsoft/garnet · error · ACLPasswordException
Unable to parse input password hash. The input is not of the
Error message
Unable to parse input password hash. The input is not of the correct format.
What it means
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.
Source
Thrown at libs/server/ACL/ACLPassword.cs:66
{
if (hashString.Length != 2 * NumHashBytes)
{
throw new ACLPasswordException("Unable to parse input password hash. The input is of wrong length.");
}
// Parse input byte by byte
byte[] hash = new byte[NumHashBytes];
try
{
for (int i = 0; i < hash.Length; i++)
{
string byteString = hashString.Substring(i * 2, 2);
hash[i] = byte.Parse(byteString, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
}
}
catch (FormatException)
{
throw new ACLPasswordException("Unable to parse input password hash. The input is not of the correct format.");
}
return new ACLPassword(hash);
}
/// <summary>
/// Outputs the hexadecimal representation of the password hash.
/// </summary>
/// <returns>Password hash as hex-string.</returns>
public override string ToString()
{
var stringBuilder = new StringBuilder();
for (int i = 0; i < PasswordHash.Length; i++)
{
stringBuilder.Append(PasswordHash[i].ToString("x2"));
}
View on GitHub (pinned to 951b0fc683)
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.
Example fix
// before
var p = ACLPassword.ACLPasswordFromHash("ab:cd:...:ef"); // 64 chars with colons
// after
var clean = new string(hash.Where(char.IsLetterOrDigit).ToArray());
var p = ACLPassword.ACLPasswordFromHash(clean); Defensive patterns
Strategy: validation
Validate before calling
if (!System.Text.RegularExpressions.Regex.IsMatch(hashString, @"^[0-9a-fA-F]{64}$"))
throw new ArgumentException("Password hash must be 64 hexadecimal characters."); Type guard
static bool IsHexHash(string s) =>
s != null && s.Length == 64 && System.Text.RegularExpressions.Regex.IsMatch(s, @"^[0-9a-fA-F]{64}$"); Try / catch
try { var p = ACLPassword.ACLPasswordFromHash(hash); }
catch (ACLPasswordException ex) when (ex.Message.Contains("format")) { /* strip separators, retry */ } Prevention
- Strip colons/dashes/spaces from hashes before parsing.
- Validate with ^[0-9a-fA-F]{64}$ before calling.
- Regenerate from cleartext if format is uncertain.
When it happens
Trigger: 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:...').
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unable to parse input password hash. The input is of wrong l
- {exception.Message}
- Malformed ACL rule
- ACL rules need to start with the USER keyword
- {categoryName}
AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13).
Data as JSON: /api/errors/da6ca84d6c60ffe9.
Report an issue: GitHub.