apache/flink · error · IllegalArgumentException
Cannot parse ApplicationID from "{hexString}". The expected
Error message
Cannot parse ApplicationID from "{hexString}". The expected format is [0-9a-fA-F]{32}, e.g. fd72014d4c864993a2e5a9287b4a9c5d. What it means
Thrown by ApplicationID.fromHexString when the input cannot be decoded into the 16-byte (128-bit) identifier. ApplicationID is a fixed-size AbstractID; its hex form must be exactly 32 hex characters. Any malformed input (wrong length, non-hex chars, null) causes StringUtils.hexStringToByte to throw, which is wrapped into this IllegalArgumentException with the offending value.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/common/ApplicationID.java:102
public static ApplicationID fromByteBuffer(ByteBuffer buf) {
long lower = buf.getLong();
long upper = buf.getLong();
return new ApplicationID(lower, upper);
}
/**
* Parses an ApplicationID from the given string.
*
* @param hexString string representation of an ApplicationID
* @return Parsed ApplicationID
* @throws IllegalArgumentException if the ApplicationID could not be parsed from the given
* string
*/
public static ApplicationID fromHexString(String hexString) {
try {
return new ApplicationID(StringUtils.hexStringToByte(hexString));
} catch (Exception e) {
throw new IllegalArgumentException(
"Cannot parse ApplicationID from \""
+ hexString
+ "\". The expected format is "
+ "[0-9a-fA-F]{32}, e.g. fd72014d4c864993a2e5a9287b4a9c5d.",
e);
}
}
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Validate the input with a regex ^[0-9a-fA-F]{32}$ before calling fromHexString, and trim whitespace.
- If reading from an external source, strip prefixes/suffixes and confirm length == 32.
- Generate IDs only via new ApplicationID() and persist the result of toString()/toHexString(); never hand-build the string.
Example fix
// before
ApplicationID id = ApplicationID.fromHexString(raw);
// after
String hex = raw == null ? "" : raw.trim();
if (!hex.matches("[0-9a-fA-F]{32}")) {
throw new IllegalArgumentException("Invalid ApplicationID: " + raw);
}
ApplicationID id = ApplicationID.fromHexString(hex); Defensive patterns
Strategy: validation
Validate before calling
String hex = hexString == null ? "" : hexString.trim();
if (!hex.matches("[0-9a-fA-F]{32}")) {
throw new IllegalArgumentException("Invalid ApplicationID hex: " + hexString);
}
ApplicationID id = ApplicationID.fromHexString(hex); Type guard
public static boolean isValidApplicationIdHex(String s) {
return s != null && s.trim().matches("[0-9a-fA-F]{32}");
} Try / catch
try { ApplicationID id = ApplicationID.fromHexString(raw); }
catch (IllegalArgumentException e) { /* log bad input, reject */ } Prevention
- Only persist IDs produced by toString()/toHexString(); never hand-build.
- Trim and regex-validate external strings before parsing.
- Keep a single helper that both validates and parses.
When it happens
Trigger: Calling ApplicationID.fromHexString(badString) where badString is null, shorter/longer than 32 chars, or contains non-hex characters. Also triggered by round-trip errors when serializing an ApplicationID through a system that truncated or re-encoded the string.
Common situations: Parsing an ApplicationID from a REST response, log line, or environment variable that has surrounding whitespace or a prefix; copying an ID that lost characters;混淆 between ApplicationID and JobID hex formats.
Related errors
- Cannot parse JobID from "{hexString}". The expected format i
- Unsupported serializer type %s for %s
- Value for configuration key='${key}' is not set correctly. E
- negative duration is not supported
- Error parsing arguments '%s' on '%s'. Please prefix keys wit
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/89469963165be7d7.
Report an issue: GitHub.