{"record":{"id":"94e79a445ef52671","repo":"apache/flink","slug":"memory-size-unit-unit-does-not-match-any-of-th","errorCode":null,"errorMessage":"Memory size unit '{unit}' does not match any of the recognized units: {MemoryUnit.getAllUnits()}","messagePattern":"Memory size unit '(.+?)' does not match any of the recognized units: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core-api/src/main/java/org/apache/flink/configuration/MemorySize.java","lineNumber":326,"sourceCode":"                            + \"' cannot be re represented as 64bit number of bytes (numeric overflow).\");\n        }\n\n        return result;\n    }\n\n    private static Optional<MemoryUnit> parseUnit(String unit) {\n        if (matchesAny(unit, BYTES)) {\n            return Optional.of(BYTES);\n        } else if (matchesAny(unit, KILO_BYTES)) {\n            return Optional.of(KILO_BYTES);\n        } else if (matchesAny(unit, MEGA_BYTES)) {\n            return Optional.of(MEGA_BYTES);\n        } else if (matchesAny(unit, GIGA_BYTES)) {\n            return Optional.of(GIGA_BYTES);\n        } else if (matchesAny(unit, TERA_BYTES)) {\n            return Optional.of(TERA_BYTES);\n        } else if (!unit.isEmpty()) {\n            throw new IllegalArgumentException(\n                    \"Memory size unit '\"\n                            + unit\n                            + \"' does not match any of the recognized units: \"\n                            + MemoryUnit.getAllUnits());\n        }\n\n        return Optional.empty();\n    }\n\n    private static boolean matchesAny(String str, MemoryUnit unit) {\n        for (String s : unit.getUnits()) {\n            if (s.equals(str)) {\n                return true;\n            }\n        }\n        return false;\n    }\n","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core-api/src/main/java/org/apache/flink/configuration/MemorySize.java#L308-L344","documentation":"MemorySize.parseBytes (via parseUnit) throws IllegalArgumentException listing all recognized units when the trailing unit string matches none of them. Units are case-insensitive but must exactly match a supported spelling (b/bytes, k/kb/kilo..., m/mb/mega..., g/gb/giga..., t/tb/tera...). Note decimal separators are not stripped: '1.5gb' parses number '1' and unit '.5gb', landing here.","triggerScenarios":"parseBytes(\"1.5gb\") (dot becomes part of the unit); parseBytes(\"100pb\") or \"100xb\"; unit typos like 'gm' or 'mbyte'; values like \"1 gb \" are fine after trim/lowercase but \"1g-b\" is not.","commonSituations":"Decimal memory values in config (unsupported — must use whole numbers with a smaller unit); using SI-only or vendor-specific unit spellings Flink does not recognize; stray punctuation attached to the unit.","solutions":["Use a recognized unit: b/bytes, kb, mb, gb, tb (case-insensitive) with a whole number","Convert decimals to a smaller unit: 1.5gb -> 1536mb","Remove stray characters/punctuation around the unit in the config value"],"exampleFix":"# before\ntaskmanager.memory.framework.heap.size: 1.5gb\n\n# after\ntaskmanager.memory.framework.heap.size: 1536mb","handlingStrategy":"validation","validationCode":"private static final Pattern SIZE = Pattern.compile(\"\\\\d+(b|bytes|k|kb|kb(s)?|m|mb|g|gb|t|tb)\", Pattern.CASE_INSENSITIVE);\nif (!SIZE.matcher(raw.trim()).matches()) {\n    throw new IllegalArgumentException(\"Unrecognized memory size format: '\" + raw + \"'\");\n}\nlong bytes = MemorySize.parseBytes(raw);","typeGuard":null,"tryCatchPattern":"catch (IllegalArgumentException e) { /* message lists all valid units — surface it to the user for config fixes */ }","preventionTips":["Use only recognized units: b/bytes, kb, mb, gb, tb (case-insensitive)","No decimals: 1.5gb is invalid ('.5gb' becomes an unrecognized unit); use 1536mb","Keep the unit glued to the number with no stray punctuation"],"tags":["memory","parsing","configuration","units","flink-core-api"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}