gradle/gradle · error · IllegalArgumentException
Invalid hash code length: %d characters
Error message
Invalid hash code length: %d characters
What it means
Error "Invalid hash code length: %d characters" thrown in gradle/gradle.
Source
Thrown at platforms/core-execution/hashing/src/main/java/org/gradle/internal/hash/HashCode.java:96
}
/**
* Decodes the hash code from a string.
* <p>
* A corresponding operation for encoding/decoding is {@link #toString()}:
* <pre>{@code
* assertEquals(hash, HashCode.fromString(hash.toString()))
* }</pre>
* <p>
* This method does not work with {@link #toCompactString()}.
*/
public static HashCode fromString(String string) {
int length = string.length();
if (length % 2 != 0
|| length < MIN_NUMBER_OF_BYTES * 2
|| length > MAX_NUMBER_OF_BYTES * 2) {
throw new IllegalArgumentException(String.format("Invalid hash code length: %d characters", length));
}
byte[] bytes = new byte[length / 2];
for (int i = 0; i < length; i += 2) {
int ch1 = decode(string.charAt(i)) << 4;
int ch2 = decode(string.charAt(i + 1));
bytes[i / 2] = (byte) (ch1 + ch2);
}
return fromBytes(bytes, SAFE_TO_REUSE_BYTES);
}
private static int decode(char ch) {
if (ch >= '0' && ch <= '9') {
return ch - '0';
}
if (ch >= 'a' && ch <= 'f') {
return ch - 'a' + 10;View on GitHub (pinned to 534f27719b)
Solutions
- The hash hex string has an invalid length. Supply a hex string of the correct character length for the algorithm.
When it happens
Trigger: Thrown at platforms/core-execution/hashing/src/main/java/org/gradle/internal/hash/HashCode.java:96 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/ae9f22210c889c08.
Report an issue: GitHub.