{"record":{"id":"89469963165be7d7","repo":"apache/flink","slug":"cannot-parse-applicationid-from-hexstring-the","errorCode":null,"errorMessage":"Cannot parse ApplicationID from \"{hexString}\". The expected format is [0-9a-fA-F]{32}, e.g. fd72014d4c864993a2e5a9287b4a9c5d.","messagePattern":"Cannot parse ApplicationID from \"(.+?)\"\\. The expected format is \\[0-9a-fA-F\\](.+?), e\\.g\\. fd72014d4c864993a2e5a9287b4a9c5d\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/ApplicationID.java","lineNumber":102,"sourceCode":"    public static ApplicationID fromByteBuffer(ByteBuffer buf) {\n        long lower = buf.getLong();\n        long upper = buf.getLong();\n        return new ApplicationID(lower, upper);\n    }\n\n    /**\n     * Parses an ApplicationID from the given string.\n     *\n     * @param hexString string representation of an ApplicationID\n     * @return Parsed ApplicationID\n     * @throws IllegalArgumentException if the ApplicationID could not be parsed from the given\n     *     string\n     */\n    public static ApplicationID fromHexString(String hexString) {\n        try {\n            return new ApplicationID(StringUtils.hexStringToByte(hexString));\n        } catch (Exception e) {\n            throw new IllegalArgumentException(\n                    \"Cannot parse ApplicationID from \\\"\"\n                            + hexString\n                            + \"\\\". The expected format is \"\n                            + \"[0-9a-fA-F]{32}, e.g. fd72014d4c864993a2e5a9287b4a9c5d.\",\n                    e);\n        }\n    }\n}\n","sourceCodeStart":84,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/ApplicationID.java#L84-L111","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nApplicationID id = ApplicationID.fromHexString(raw);\n// after\nString hex = raw == null ? \"\" : raw.trim();\nif (!hex.matches(\"[0-9a-fA-F]{32}\")) {\n    throw new IllegalArgumentException(\"Invalid ApplicationID: \" + raw);\n}\nApplicationID id = ApplicationID.fromHexString(hex);","handlingStrategy":"validation","validationCode":"String hex = hexString == null ? \"\" : hexString.trim();\nif (!hex.matches(\"[0-9a-fA-F]{32}\")) {\n    throw new IllegalArgumentException(\"Invalid ApplicationID hex: \" + hexString);\n}\nApplicationID id = ApplicationID.fromHexString(hex);","typeGuard":"public static boolean isValidApplicationIdHex(String s) {\n    return s != null && s.trim().matches(\"[0-9a-fA-F]{32}\");\n}","tryCatchPattern":"try { ApplicationID id = ApplicationID.fromHexString(raw); }\ncatch (IllegalArgumentException e) { /* log bad input, reject */ }","preventionTips":["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."],"tags":["application-id","parsing","hex","validation"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}